LOGGER: enhancing prepare_component

This commit is contained in:
XargonWan 2024-02-29 20:55:16 +01:00
parent 94a730029b
commit 9cf09bd54f

View file

@ -13,6 +13,8 @@ prepare_component() {
component="$2" component="$2"
call_source="$3" call_source="$3"
log d "Preparing component: \"$component\", action: \"$action\""
if [[ "$component" == "retrodeck" ]]; then if [[ "$component" == "retrodeck" ]]; then
if [[ "$action" == "reset" ]]; then # Update the paths of all folders in retrodeck.cfg and create them if [[ "$action" == "reset" ]]; then # Update the paths of all folders in retrodeck.cfg and create them
while read -r config_line; do while read -r config_line; do
@ -41,12 +43,10 @@ prepare_component() {
fi fi
if [[ "$component" =~ ^(es-de|ES-DE|all)$ ]]; then # For use after ESDE-related folders are moved or a reset if [[ "$component" =~ ^(es-de|ES-DE|all)$ ]]; then # For use after ESDE-related folders are moved or a reset
log d "Preparing component: ES-DE"
if [[ "$action" == "reset" ]]; then if [[ "$action" == "reset" ]]; then
log d "Reset action si triggered for: ES-DE"
rm -rf /var/config/ES-DE rm -rf /var/config/ES-DE
create_dir /var/config/ES-DE/settings create_dir /var/config/ES-DE/settings
log d "Initializing es_settings.xml" log d "Prepearing es_settings.xml"
cp -f /app/retrodeck/es_settings.xml /var/config/ES-DE/settings/es_settings.xml cp -f /app/retrodeck/es_settings.xml /var/config/ES-DE/settings/es_settings.xml
set_setting_value "$es_settings" "ROMDirectory" "$roms_folder" "es_settings" set_setting_value "$es_settings" "ROMDirectory" "$roms_folder" "es_settings"
set_setting_value "$es_settings" "MediaDirectory" "$media_folder" "es_settings" set_setting_value "$es_settings" "MediaDirectory" "$media_folder" "es_settings"
@ -93,7 +93,7 @@ prepare_component() {
# PPSSPP # PPSSPP
log i "--------------------------------" log i "--------------------------------"
log i "Initializing PPSSPP_LIBRETRO" log i "Prepearing PPSSPP_LIBRETRO"
log i "--------------------------------" log i "--------------------------------"
if [ -d $bios_folder/PPSSPP/flash0/font ] if [ -d $bios_folder/PPSSPP/flash0/font ]
then then
@ -107,14 +107,14 @@ prepare_component() {
# MSX / SVI / ColecoVision / SG-1000 # MSX / SVI / ColecoVision / SG-1000
log i "-----------------------------------------------------------" log i "-----------------------------------------------------------"
log i "Initializing MSX / SVI / ColecoVision / SG-1000 LIBRETRO" log i "Prepearing MSX / SVI / ColecoVision / SG-1000 LIBRETRO"
log i "-----------------------------------------------------------" log i "-----------------------------------------------------------"
cp -rf "/app/retrodeck/extras/MSX/Databases" "$bios_folder/Databases" cp -rf "/app/retrodeck/extras/MSX/Databases" "$bios_folder/Databases"
cp -rf "/app/retrodeck/extras/MSX/Machines" "$bios_folder/Machines" cp -rf "/app/retrodeck/extras/MSX/Machines" "$bios_folder/Machines"
# AMIGA # AMIGA
log i "-----------------------------------------------------------" log i "-----------------------------------------------------------"
log i "Initializing AMIGA LIBRETRO" log i "Prepearing AMIGA LIBRETRO"
log i "-----------------------------------------------------------" log i "-----------------------------------------------------------"
cp -f "/app/retrodeck/extras/Amiga/capsimg.so" "$bios_folder/capsimg.so" cp -f "/app/retrodeck/extras/Amiga/capsimg.so" "$bios_folder/capsimg.so"
@ -162,7 +162,7 @@ prepare_component() {
if [[ "$component" =~ ^(cemu|Cemu|all)$ ]]; then if [[ "$component" =~ ^(cemu|Cemu|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing CEMU" log i "Prepearing CEMU"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/Cemu" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/Cemu"
@ -189,7 +189,7 @@ prepare_component() {
if [[ "$component" =~ ^(citra|citra-emu|Citra|all)$ ]]; then if [[ "$component" =~ ^(citra|citra-emu|Citra|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "------------------------" log i "------------------------"
log i "Initializing CITRA" log i "Prepearing CITRA"
log i "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/citra-emu" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/citra-emu"
@ -234,7 +234,7 @@ prepare_component() {
if [[ "$component" =~ ^(dolphin|dolphin-emu|Dolphin|all)$ ]]; then if [[ "$component" =~ ^(dolphin|dolphin-emu|Dolphin|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing DOLPHIN" log i "Prepearing DOLPHIN"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu"
@ -287,7 +287,7 @@ prepare_component() {
if [[ "$component" =~ ^(duckstation|Duckstation|all)$ ]]; then if [[ "$component" =~ ^(duckstation|Duckstation|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "------------------------" log i "------------------------"
log i "Initializing DUCKSTATION" log i "Prepearing DUCKSTATION"
log i "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/data/duckstation/" create_dir -d "$multi_user_data_folder/$SteamAppUser/data/duckstation/"
@ -332,7 +332,7 @@ prepare_component() {
if [[ "$component" =~ ^(melonds|melonDS|MelonDS|all)$ ]]; then if [[ "$component" =~ ^(melonds|melonDS|MelonDS|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing MELONDS" log i "Prepearing MELONDS"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/melonDS/" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/melonDS/"
@ -370,7 +370,7 @@ prepare_component() {
if [[ "$component" =~ ^(pcsx2|PCSX2|all)$ ]]; then if [[ "$component" =~ ^(pcsx2|PCSX2|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing PCSX2" log i "Prepearing PCSX2"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis"
@ -424,7 +424,7 @@ prepare_component() {
if [[ "$component" =~ ^(ppsspp|PPSSPP|all)$ ]]; then if [[ "$component" =~ ^(ppsspp|PPSSPP|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "------------------------" log i "------------------------"
log i "Initializing PPSSPPSDL" log i "Prepearing PPSSPPSDL"
log i "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/"
@ -452,7 +452,7 @@ prepare_component() {
if [[ "$component" =~ ^(primehack|Primehack|all)$ ]]; then if [[ "$component" =~ ^(primehack|Primehack|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing Primehack" log i "Prepearing Primehack"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/primehack" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/primehack"
@ -494,7 +494,7 @@ prepare_component() {
if [[ "$component" =~ ^(rpcs3|RPCS3|all)$ ]]; then if [[ "$component" =~ ^(rpcs3|RPCS3|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "------------------------" log i "------------------------"
log i "Initializing RPCS3" log i "Prepearing RPCS3"
log i "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/rpcs3/" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/rpcs3/"
@ -532,7 +532,7 @@ prepare_component() {
# When RetroDECK starts there is a "manage_ryujinx_keys" function that symlinks the keys only in Rryujinx/system. # When RetroDECK starts there is a "manage_ryujinx_keys" function that symlinks the keys only in Rryujinx/system.
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "------------------------" log i "------------------------"
log i "Initializing RYUJINX" log i "Prepearing RYUJINX"
log i "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then if [[ $multi_user_mode == "true" ]]; then
rm -rf "$multi_user_data_folder/$SteamAppUser/config/Ryujinx" rm -rf "$multi_user_data_folder/$SteamAppUser/config/Ryujinx"
@ -546,11 +546,14 @@ prepare_component() {
# TODO: add "registered" folder management # TODO: add "registered" folder management
else else
# removing config directory to wipe legacy files # removing config directory to wipe legacy files
log d "Removing \"/var/config/Ryujinx\""
rm -rf /var/config/Ryujinx rm -rf /var/config/Ryujinx
create_dir /var/config/Ryujinx/system create_dir /var/config/Ryujinx/system
cp -fv $emuconfigs/ryujinx/* /var/config/Ryujinx cp -fv $emuconfigs/ryujinx/* /var/config/Ryujinx
log d "Replacing placeholders in \"$ryujinxconf\""
sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$ryujinxconf" sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$ryujinxconf"
# Linking switch nand/saves folder log i "Linking switch nand/saves folder"
log d "Removing \"/var/config/Ryujinx/bis\", it will become a symlink"
rm -rf /var/config/Ryujinx/bis rm -rf /var/config/Ryujinx/bis
dir_prep "$saves_folder/switch/ryujinx/nand" "/var/config/Ryujinx/bis" dir_prep "$saves_folder/switch/ryujinx/nand" "/var/config/Ryujinx/bis"
dir_prep "$saves_folder/switch/ryujinx/sdcard" "/var/config/Ryujinx/sdcard" dir_prep "$saves_folder/switch/ryujinx/sdcard" "/var/config/Ryujinx/sdcard"
@ -561,6 +564,7 @@ prepare_component() {
# dir_prep "$bios_folder/switch/keys" "/var/config/Ryujinx/system" # dir_prep "$bios_folder/switch/keys" "/var/config/Ryujinx/system"
# fi # fi
if [[ "$action" == "postmove" ]]; then # Run only post-move commands if [[ "$action" == "postmove" ]]; then # Run only post-move commands
log d "Replacing placeholders in \"$ryujinxconf\""
sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$ryujinxconf" # This is an unfortunate one-off because set_setting_value does not currently support JSON sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "$ryujinxconf" # This is an unfortunate one-off because set_setting_value does not currently support JSON
fi fi
fi fi
@ -568,7 +572,7 @@ prepare_component() {
if [[ "$component" =~ ^(xemu|XEMU|all)$ ]]; then if [[ "$component" =~ ^(xemu|XEMU|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "------------------------" log i "------------------------"
log i "Initializing XEMU" log i "Prepearing XEMU"
log i "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf /var/config/xemu rm -rf /var/config/xemu
@ -612,7 +616,7 @@ prepare_component() {
if [[ "$component" =~ ^(yuzu|Yuzu|all)$ ]]; then if [[ "$component" =~ ^(yuzu|Yuzu|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing YUZU" log i "Prepearing YUZU"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
create_dir -d "$multi_user_data_folder/$SteamAppUser/config/yuzu" create_dir -d "$multi_user_data_folder/$SteamAppUser/config/yuzu"
@ -666,7 +670,7 @@ prepare_component() {
if [[ "$component" =~ ^(vita3k|Vita3K|all)$ ]]; then if [[ "$component" =~ ^(vita3k|Vita3K|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
log i "----------------------" log i "----------------------"
log i "Initializing Vita3K" log i "Prepearing Vita3K"
log i "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
log d "Figure out what Vita3k needs for multi-user" log d "Figure out what Vita3k needs for multi-user"
@ -691,7 +695,7 @@ prepare_component() {
# TODO: do a proper script # TODO: do a proper script
# This is just a placeholder script to test the emulator's flow # This is just a placeholder script to test the emulator's flow
log i "----------------------" log i "----------------------"
log i "Initializing MAME" log i "Prepearing MAME"
log i "----------------------" log i "----------------------"
# TODO: probably some of these needs to be put elsewhere # TODO: probably some of these needs to be put elsewhere
@ -756,7 +760,7 @@ prepare_component() {
# TODO: do a proper script # TODO: do a proper script
# This is just a placeholder script to test the emulator's flow # This is just a placeholder script to test the emulator's flow
log i "----------------------" log i "----------------------"
log i "Initializing GZDOOM" log i "Prepearing GZDOOM"
log i "----------------------" log i "----------------------"
create_dir "/var/config/gzdoom" create_dir "/var/config/gzdoom"
@ -770,7 +774,7 @@ prepare_component() {
if [[ "$component" =~ ^(boilr|BOILR|all)$ ]]; then if [[ "$component" =~ ^(boilr|BOILR|all)$ ]]; then
log i "----------------------" log i "----------------------"
log i "Initializing BOILR" log i "Prepearing BOILR"
log i "----------------------" log i "----------------------"
create_dir "/var/config/boilr" create_dir "/var/config/boilr"