#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius) . /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. ################################################################################ ### Fix docker storage path (dev build issue only) if [ -e "/usr/bin/docker" ] && \ [ ! -d "/storage/.config/docker" ] then cp -rf /usr/config/docker /storage/.config fi ### Ensure panel properties exist. for DPROP in brightness contrast saturation hue do DBRI=$(get_setting display.${DPROP}) if [ -z "${DBRI}" ] then set_setting display.${DPROP} 50 fi done ### Update JSListen for JSL in jslisten_hotkeys jslisten_profile do cp -f /usr/config/${JSL} /storage/.config done ### Add properties for enhanced power savings control. AUDIOPOWERSAVE=$(get_setting system.power.audio) if [ -z "${AUDIOPOWERSAVE}" ] then set_setting system.power.audio 1 fi CPUPOWERSAVE=$(get_setting system.power.cpu) if [ -z "${CPUPOWERSAVE}" ] then set_setting system.power.cpu 1 fi PCIEPOWERSAVE=$(get_setting system.power.pcie) if [ -z "${PCIEPOWERSAVE}" ] then set_setting system.power.pcie 0 fi RTPM=$(get_setting system.power.rtpm) if [ -z "${RTPM}" ] then set_setting system.power.rtpm 0 fi WAKEEVENTS=$(get_setting system.power.wakeevents) if [ -z "${WAKEEVENTS}" ] then set_setting system.power.wakeevents 0 fi WIFIPOWERSAVE=$(get_setting system.power.wifi) if [ -z "${WIFIPOWERSAVE}" ] then set_setting system.power.wifi 0 fi AUDIBLEALERT=$(get_setting system.battery.warning) if [ -z "${AUDIBLEALERT}" ] then set_setting system.battery.warning 1 fi ### Revert the recent ES PowerSavingMode change. sed -i 's##g' /storage/.config/emulationstation/es_settings.cfg ### Remove properties containing "auto" from the system config. sed -i "/^.*=auto/d" /storage/.config/system/configs/system.cfg ### Fix up music player to start selection if [ -d "/storage/.local/share/gmu" ] then rm -rf /storage/.local/share/gmu fi if [ ! -d "/storage/.config/gmu/playlists" ] then mkdir -p /storage/.config/gmu/playlists fi cp -rf /usr/config/gmu/playlists/* /storage/.config/gmu/playlists/ ### Switch back to alsathread sed -i 's~^audio_driver = .*$~audio_driver = "alsathread"~g' /storage/.config/retroarch/retroarch.cfg ### Remove stale asound bits rm -f /storage/.config/asound* ### Flycast needs to switch to pulseaudio if [ -e "/storage/.config/flycast/emu.cfg" ] then cp -f /usr/config/flycast/emu.cfg /storage/.config/flycast/emu.cfg fi ### Dolphin needs to switch to pulseaudio if [ -e "/storage/.config/dolphin-emu/Dolphin.ini" ] then sed -i 's/Backend =.*$/Backend = Pulse/g' /storage/.config/dolphin-emu/Dolphin.ini fi ### Set the default output to Master for pipewire ES_SETTINGS="/storage/.config/emulationstation/es_settings.cfg" function set_es_path() { AUDIODEVICE=${1} sed -i '/^.*' ${ES_SETTINGS} echo "DEVICE_AUDIO_MIXER=\"${AUDIODEVICE}\"" >/storage/.config/profile.d/99-mixer } set_es_path "Master" ### Set default audio latency LATENCY=$(get_setting global.audiolatency) if [ -z "${LATENCY}" ] then set_setting global.audiolatency 32 fi