distribution/packages/jelos/sources/post-update

111 lines
3.9 KiB
Bash

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
LOG="/var/log/boot.log"
### This script contains items that we only want to execute after a JELOS upgrade,
### or after a fresh installation.
### Items in this block should always run after updates.
################################################################################
echo "Rebuild library cache..." >>${LOG}
### Rebuild the library cache
rm -f /storage/.cache/ld.so.cache
ldconfig -X
echo "Sync configuration files..." >>${LOG}
### Sync configurations
if [ -d "/storage/.config/system/configs" ]
then
EXCLUDE="--exclude=configs"
fi
### Remove and link es configs so they are managed with OS updates.
for es_cfg in es_features.cfg es_systems.cfg
do
mv /storage/.config/emulationstation/${es_cfg} /storage/.config/emulationstation/last_${es_cfg} >/dev/null 2>&1
ln -s /usr/config/emulationstation/${es_cfg} /storage/.config/emulationstation/${es_cfg} >/dev/null 2>&1
done
rsync -a --delete ${EXCLUDE} /usr/config/system/ /storage/.config/system/
rsync -a --ignore-existing /usr/config/game /storage/.config/
rsync -a /usr/config/modules /storage/.config/
if [ -f "/storage/.config/emulationstation/resources/logo.png" ]
then
rm -f /storage/.config/emulationstation/resources/logo.png
fi
echo "Sync modules..." >>${LOG}
rsync -a /usr/config/modules/* /storage/.config/modules/
cp -f /usr/config/retroarch/retroarch-core-options.cfg /storage/.config/retroarch/retroarch-core-options.cfg
### Apply developer ssh keys if they exist
echo "Apply dev keys if available..." >>${LOG}
if [ -e /usr/config/ssh/authorized_keys ]
then
cp /usr/config/ssh/authorized_keys /storage/.ssh
fi
### Sync rsync configs
echo "Update rsync configuration files..." >>${LOG}
rsync --ignore-existing /usr/config/rsync-rules.conf /storage/.config/
rsync --ignore-existing /usr/config/rsync.conf /storage/.config/
### Sync locale data
rsync -a --delete /usr/config/locale/* /storage/.config/locale/ >>/var/log/configure.log 2>&1
rm -rf /storage/.config/emulationstation/locale >>/var/log/configure.log 2>&1 ||:
ln -sf /usr/share/locale /storage/.config/emulationstation/locale >>/var/log/configure.log 2>&1 ||:
### Add items below this line that are safe to remove after a period of time.
################################################################################
### Added 20230409 as a helper for the quirks refactor.
if [ ! -d "/storage/.config/profile_backup" ]
then
mkdir /storage/.config/profile_backup
mv /storage/.config/profile.d/* /storage/.config/profile_backup
fi
### 20230913 (reverted) Set the default output to Master for pipewire
ES_SETTINGS="/storage/.config/emulationstation/es_settings.cfg"
function set_es_path() {
AUDIODEVICE=${1}
sed -i '/^.*<string name="AudioDevice".*$/d' ${ES_SETTINGS}
if [ -e "/storage/.config/profile.d/99-mixer" ]
then
rm "/storage/.config/profile.d/99-mixer"
fi
sed -i '/^.*AudioCard.*$/a \\t<string name="AudioDevice" value="'"${AUDIODEVICE}"'" \/>' ${ES_SETTINGS}
echo "DEVICE_AUDIO_MIXER=\"${AUDIODEVICE}\"" >/storage/.config/profile.d/99-mixer
}
set_es_path "Master"
### 20230913 (reverted) Set default audio latency
LATENCY=$(get_setting global.audiolatency)
if [ -z "${LATENCY}" ]
then
set_setting global.audiolatency 32
fi
### 20230915 - Apply a rewind global if it doesn't exist.
REWIND=$(get_setting global.rewind)
if [ -z "${REWIND}" ]
then
set_setting global.rewind 0
fi
### 20230915 - Delete any stale alsa configs.
rm -f /storage/.config/asound*
### 20230916 - Disable Retrarch's built in image viewer so fake-08 blobs are opened correctly. Thanks to christianhaitian and jtothebell.
sed -i 's~builtin_imageviewer_enable.*$~builtin_imageviewer_enable = "false"~g' /storage/.config/retroarch/retroarch.cfg
### 20231010 - Stop setting vram in ES settings.
sed -i '/^.*<int name="MaxVRAM".*$/d' ${ES_SETTINGS}