LOGGER: more enhancements to functions.sh and post_update.sh

This commit is contained in:
XargonWan 2024-01-08 14:42:09 +01:00
parent 97397b6dca
commit a73bb5cb9b
2 changed files with 24 additions and 20 deletions

View file

@ -18,6 +18,7 @@ directory_browse() {
if [ $? == 0 ] if [ $? == 0 ]
then then
path_selected=true path_selected=true
log i "\"$target\" selected."
echo "$target" echo "$target"
break break
fi fi
@ -48,6 +49,7 @@ file_browse() {
if [ $? == 0 ] if [ $? == 0 ]
then then
file_selected=true file_selected=true
log i "\"$target\" selected."
echo "$target" echo "$target"
break break
fi fi
@ -201,51 +203,51 @@ dir_prep() {
real="$1" real="$1"
symlink="$2" symlink="$2"
echo -e "\n[DIR PREP]\nMoving $symlink in $real" #DEBUG log d "[DIR PREP]\nMoving $symlink in $real" #DEBUG
# if the symlink dir is already a symlink, unlink it first, to prevent recursion # if the symlink dir is already a symlink, unlink it first, to prevent recursion
if [ -L "$symlink" ]; if [ -L "$symlink" ];
then then
echo "$symlink is already a symlink, unlinking to prevent recursives" #DEBUG log d "$symlink is already a symlink, unlinking to prevent recursives" #DEBUG
unlink "$symlink" unlink "$symlink"
fi fi
# if the dest dir exists we want to backup it # if the dest dir exists we want to backup it
if [ -d "$symlink" ]; if [ -d "$symlink" ];
then then
echo "$symlink found" #DEBUG log d "$symlink found" #DEBUG
mv -f "$symlink" "$symlink.old" mv -f "$symlink" "$symlink.old"
fi fi
# if the real dir is already a symlink, unlink it first # if the real dir is already a symlink, unlink it first
if [ -L "$real" ]; if [ -L "$real" ];
then then
echo "$real is already a symlink, unlinking to prevent recursives" #DEBUG log d "$real is already a symlink, unlinking to prevent recursives" #DEBUG
unlink "$real" unlink "$real"
fi fi
# if the real dir doesn't exist we create it # if the real dir doesn't exist we create it
if [ ! -d "$real" ]; if [ ! -d "$real" ];
then then
echo "$real not found, creating it" #DEBUG log d "$real not found, creating it" #DEBUG
mkdir -pv "$real" mkdir -pv "$real"
fi fi
# creating the symlink # creating the symlink
echo "linking $real in $symlink" #DEBUG log d "linking $real in $symlink" #DEBUG
mkdir -pv "$(dirname "$symlink")" # creating the full path except the last folder mkdir -pv "$(dirname "$symlink")" # creating the full path except the last folder
ln -svf "$real" "$symlink" ln -svf "$real" "$symlink"
# moving everything from the old folder to the new one, delete the old one # moving everything from the old folder to the new one, delete the old one
if [ -d "$symlink.old" ]; if [ -d "$symlink.old" ];
then then
echo "Moving the data from $symlink.old to $real" #DEBUG log d "Moving the data from $symlink.old to $real" #DEBUG
mv -f "$symlink.old"/{.[!.],}* $real mv -f "$symlink.old"/{.[!.],}* $real
echo "Removing $symlink.old" #DEBUG log d "Removing $symlink.old" #DEBUG
rm -rf "$symlink.old" rm -rf "$symlink.old"
fi fi
echo -e "$symlink is now $real\n" log i "$symlink is now $real\n"
} }
update_rpcs3_firmware() { update_rpcs3_firmware() {
@ -290,6 +292,7 @@ do
if [ $? == 0 ] #yes if [ $? == 0 ] #yes
then then
path_selected=true path_selected=true
log i "\"$target/retrodeck\" selected."
echo "$target/retrodeck" echo "$target/retrodeck"
break break
else else
@ -331,28 +334,29 @@ finit_user_options_dialog() {
--column "option_flag" \ --column "option_flag" \
"${finit_available_options[@]}") "${finit_available_options[@]}")
log i "User choiches: \"${choices[*]}\"."
echo "${choices[*]}" echo "${choices[*]}"
} }
finit() { finit() {
# Force/First init, depending on the situation # Force/First init, depending on the situation
echo "Executing finit" log i "Executing finit"
# Internal or SD Card? # Internal or SD Card?
local finit_dest_choice=$(configurator_destination_choice_dialog "RetroDECK data" "Welcome to the first configuration of RetroDECK.\nThe setup will be quick but please READ CAREFULLY each message in order to avoid misconfigurations.\n\nWhere do you want your RetroDECK data folder to be located?\n\nThis folder will contain all ROMs, BIOSs and scraped data." ) local finit_dest_choice=$(configurator_destination_choice_dialog "RetroDECK data" "Welcome to the first configuration of RetroDECK.\nThe setup will be quick but please READ CAREFULLY each message in order to avoid misconfigurations.\n\nWhere do you want your RetroDECK data folder to be located?\n\nThis folder will contain all ROMs, BIOSs and scraped data." )
echo "Choice is $finit_dest_choice" log i "Choice is $finit_dest_choice"
case "$finit_dest_choice" in case "$finit_dest_choice" in
"Back" | "" ) # Back or X button quits "Back" | "" ) # Back or X button quits
rm -f "$rd_conf" # Cleanup unfinished retrodeck.cfg if first install is interrupted rm -f "$rd_conf" # Cleanup unfinished retrodeck.cfg if first install is interrupted
echo "Now quitting" log i "Now quitting"
quit_retrodeck quit_retrodeck
;; ;;
"Internal Storage" ) # Internal "Internal Storage" ) # Internal
echo "Internal selected" log i "Internal selected"
rdhome="$HOME/retrodeck" rdhome="$HOME/retrodeck"
if [[ -L "$rdhome" ]]; then #Remove old symlink from existing install, if it exists if [[ -L "$rdhome" ]]; then #Remove old symlink from existing install, if it exists
unlink "$rdhome" unlink "$rdhome"
@ -360,10 +364,10 @@ finit() {
;; ;;
"SD Card" ) "SD Card" )
echo "SD Card selected" log i "SD Card selected"
if [ ! -d "$sdcard" ] # SD Card path is not existing if [ ! -d "$sdcard" ] # SD Card path is not existing
then then
echo "Error: SD card not found" log e "SD card not found"
zenity --error --no-wrap \ zenity --error --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \ --title "RetroDECK" \
@ -376,14 +380,14 @@ finit() {
fi fi
elif [ ! -w "$sdcard" ] #SD card found but not writable elif [ ! -w "$sdcard" ] #SD card found but not writable
then then
echo "Error: SD card found but not writable" log e "SD card found but not writable"
zenity --error --no-wrap \ zenity --error --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \ --title "RetroDECK" \
--ok-label "Quit" \ --ok-label "Quit" \
--text="SD card was found but is not writable\nThis can happen with cards formatted on PC.\nPlease format the SD card through the Steam Deck's Game Mode and run RetroDECK again." --text="SD card was found but is not writable\nThis can happen with cards formatted on PC.\nPlease format the SD card through the Steam Deck's Game Mode and run RetroDECK again."
rm -f "$rd_conf" # Cleanup unfinished retrodeck.cfg if first install is interrupted rm -f "$rd_conf" # Cleanup unfinished retrodeck.cfg if first install is interrupted
echo "Now quitting" log i "Now quitting"
quit_retrodeck quit_retrodeck
else else
rdhome="$sdcard/retrodeck" rdhome="$sdcard/retrodeck"
@ -391,7 +395,7 @@ finit() {
;; ;;
"Custom Location" ) "Custom Location" )
echo "Custom Location selected" log i "Custom Location selected"
zenity --info --no-wrap \ zenity --info --no-wrap \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \ --title "RetroDECK" \

View file

@ -279,13 +279,13 @@ post_update() {
fi fi
# The save folder of rpcs3 was inverted so we're moving the saves into the real one # The save folder of rpcs3 was inverted so we're moving the saves into the real one
echo "RPCS3 saves needs to be migrated, executing." log w "RPCS3 saves needs to be migrated, executing."
mv "$saves_folder/ps3/rpcs3" "$saves_folder/ps3/rpcs3.bak" mv "$saves_folder/ps3/rpcs3" "$saves_folder/ps3/rpcs3.bak"
mkdir -p "$saves_folder/ps3/rpcs3" mkdir -p "$saves_folder/ps3/rpcs3"
mv -v "$saves_folder/ps3/rpcs3.bak"/* "$saves_folder/ps3/rpcs3" mv -v "$saves_folder/ps3/rpcs3.bak"/* "$saves_folder/ps3/rpcs3"
mv -v "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata"/* "$saves_folder/ps3/rpcs3" mv -v "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata"/* "$saves_folder/ps3/rpcs3"
mv -v "$saves_folder/ps3/rpcs3.bak" "$rdhome/backups/saves/ps3/rpcs3" mv -v "$saves_folder/ps3/rpcs3.bak" "$rdhome/backups/saves/ps3/rpcs3"
echo "RPCS3 saves migration completed, a backup was made here: \"$rdhome/backups/saves/ps3/rpcs3\"." log w "RPCS3 saves migration completed, a backup was made here: \"$rdhome/backups/saves/ps3/rpcs3\"."
source /app/libexec/functions.sh source /app/libexec/functions.sh
dir_prep "$saves_folder/ps3/rpcs3" "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata" dir_prep "$saves_folder/ps3/rpcs3" "$bios_folder/rpcs3/dev_hdd0/home/00000001/savedata"