distribution/packages/jelos/sources/post-update
fewtarius 73b7b358e8
Feature: Use overlayfs to merge internal and external storage into /storage/roms.
* Creates a new directory structure for games:
  * Internal Storage (or tf1): /storage/games-internal
  * External MicroSD: /storage/games-external
  * Combined Path: /storage/roms
* Games copied to /storage/roms will be saved to /storage/games-internal.
* Samba has been updated to present both volumes for network access.
* EmulationStation now has an eject option under System Settings -> Hardware /Storage.
* When a compatible microsd is inserted, JELOS will automatically add it to the overlay, making the content available to ES after a gamelist update or an ES restart.
* Udevil will no longer mount microsd cards to /run/media, however it will still handle mounting all other external storage.
* After the update, JELOS will automatically migrate your current roms directory once.
* Additionally the hotkey management feature has moved from System Settings to Controller and Bluetooth Settings.
* The rom split tool is now deprecated as it is no longer needed.
2023-11-27 22:41:15 +00:00

98 lines
3.4 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.
################################################################################
### 20231010 - Stop setting vram in ES settings.
sed -i '/^.*<int name="MaxVRAM".*$/d' ${ES_SETTINGS}
### 20231031 - Switch back to alsathread for RetroArch
sed -i 's~"pulse"~"alsathread"~g' /storage/.config/retroarch/retroarch.cfg
### 20231114 - Update hosts.conf
grep "127.0.0.1" /storage/.config/hosts.conf >/dev/null 2>&1 || cp /usr/config/hosts.conf /storage/.config/
### 20231127 - Migrate games to overlayfs
systemctl stop storage-roms.mount
GAMECOUNT=$(find /storage/roms -type f | wc -l)
if [ "${GAMECOUNT}" -gt 20 ] && \
[ ! -e "/storage/.migrated_games" ]
then
echo "Migrating games to overlayfs" >>${LOG}
if [ -d "/storage/games-internal" ]
then
echo "Backing up games-internal" >>${LOG}
mv /storage/games-internal /storage/games-internal.backup
fi
mv /storage/roms /storage/games-internal
mkdir /storage/roms
touch /storage/.migrated_games
else
echo "Game weight too low (${GAMECOUNT}) or content already migrated." >>${LOG}
fi
systemctl start storage-roms.mount
### Items below this line should not be removed.
tocon "Update complete, rebooting..."
reboot