distribution/packages/sysutils/systemd/scripts/userconfig-setup
fewtarius cd17e0e13c
* Fix fresh flash system menu bug.
* Fix language selection bug.
* Add DEBUG_SUPPORT variable to build debug tools.
2023-04-24 16:19:57 +00:00

96 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2017-present Team LibreELEC (https://libreelec.tv)
# Copyright (C) 2022-present Fewtarius
. /etc/profile
if [ ! -e "/storage/.configured" ]
then
tocon "Initializing configuration..."
# Copy config files, but don't overwrite. Only run if /storage is fresh
rsync -a --ignore-existing --exclude=es_systems.cfg /usr/config/* /storage/.config/ >/var/log/configure.log 2>&1
if [ -e "/usr/bin/emulationstation" ]
then
tocon "Installing themes..."
mkdir -p /storage/.config/emulationstation/themes >>/var/log/configure.log
ln -s /usr/share/themes/es-theme-art-book-next /storage/.config/emulationstation/themes/system-theme >>/var/log/configure.log 2>&1
ln -s /usr/share/themes/es-theme-minielec /storage/.config/emulationstation/themes/es-theme-minielec >>/var/log/configure.log 2>&1
ln -s /usr/share/themes/es-theme-minimal /storage/.config/emulationstation/themes/es-theme-minimal >>/var/log/configure.log 2>&1
### Link the game controller database so it is managed with OS updates.
tocon "Configuring controller database..."
rm -f /storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt >>/var/log/configure.log 2>&1
ln -s /usr/config/SDL-GameControllerDB/gamecontrollerdb.txt /storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt >>/var/log/configure.log 2>&1
### Remove and link es configs so they are managed with OS updates.
for es_cfg in es_features.cfg es_systems.cfg
do
ln -s /usr/config/emulationstation/${es_cfg} /storage/.config/emulationstation/${es_cfg} >>/var/log/configure.log 2>&1
done
### Configure the ES splash to the distribution splash
FBWIDTH=$(fbset | awk '/geometry/ {print $2}')
FBHEIGHT=$(fbset | awk '/geometry/ {print $3}')
ASPECT=$(printf "%.2f" $(echo "(${FBWIDTH} / ${FBHEIGHT})" | bc -l))
case ${ASPECT} in
1.31|0.76)
ASPECT="3:2"
;;
1.33|0.75)
ASPECT="4:3"
;;
1.67|0.60)
ASPECT="5:3"
;;
1.76|0.56)
ASPECT="16:9"
;;
esac
if [ -f "/storage/.config/emulationstation/resources/logo.png" ]
then
rm -f /storage/.config/emulationstation/resources/logo.png ||:
fi
convert /usr/config/splash/splash.png \
-gravity center \
-crop ${ASPECT} +repage \
/tmp/.logo.png
convert /tmp/.logo.png \
-quality 100 \
-resize ${FBWIDTH}x${FBHEIGHT} \
-background black \
-gravity center \
/storage/.config/emulationstation/resources/logo.png
rm -f /tmp/.logo.png
fi
mkdir -p /storage/.config/modprobe.d >>/var/log/configure.log 2>&1
touch /storage/.configured >>/var/log/configure.log 2>&1
fi
if [ ! -e "/storage/.cache/ld.so.cache" ]
then
tocon "Initializing library cache..."
### Create library cache
ldconfig -X >>/var/log/configure.log 2>&1
fi
if [ ! -d "/storage/.config/locale" ]
then
tocon "Initializing language support..."
rsync -a --delete /usr/config/locale/* /storage/.config/locale/ >>/var/log/configure.log 2>&1
if [ ! -L "/storage/.config/emulationstation/locale" ]
[ -e "/usr/bin/emulationstation" ]
then
rm -rf /storage/.config/emulationstation/locale >>/var/log/configure.log 2>&1 ||:
ln -sf /usr/share/locale /storage/.config/emulationstation/locale
fi
fi