LOGGER: more logging

This commit is contained in:
XargonWan 2024-01-04 17:34:02 +01:00
parent e365c41cd6
commit 878e3e41ca
9 changed files with 161 additions and 121 deletions

View file

@ -8,24 +8,24 @@ source /app/libexec/logger.sh
# Fetch appdata version # Fetch appdata version
appdata_version=$(fetch_appdata_version) appdata_version=$(fetch_appdata_version)
echo -e "Appdata:\t\t$appdata_version" log i "Appdata:\t\t$appdata_version"
# Defining manifest file location # Defining manifest file location
appdata_file="net.retrodeck.retrodeck.appdata.xml" appdata_file="net.retrodeck.retrodeck.appdata.xml"
# Check if release with appdata_version already exists # Check if release with appdata_version already exists
if grep -q "version=\"$appdata_version\"" "$appdata_file"; then if grep -q "version=\"$appdata_version\"" "$appdata_file"; then
echo "Deleting existing release version $appdata_version..." log i "Deleting existing release version $appdata_version..."
# Remove the existing release entry # Remove the existing release entry
sed -i "/<release version=\"$appdata_version\"/,/<\/release>/d" "$appdata_file" sed -i "/<release version=\"$appdata_version\"/,/<\/release>/d" "$appdata_file"
fi fi
echo "Adding new release version $appdata_version..." log i "Adding new release version $appdata_version..."
# Get today's date in the required format (YYYY-MM-DD) # Get today's date in the required format (YYYY-MM-DD)
today_date=$(date +"%Y-%m-%d") today_date=$(date +"%Y-%m-%d")
echo "Today is $today_date" log i "Today is $today_date"
# Construct the release snippet # Construct the release snippet
release_snippet="\ release_snippet="\

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
source /app/libexec/logger.sh
# Define the IWAD files list # Define the IWAD files list
IWAD_FILES=("DOOM1.WAD" "DOOM.WAD" "DOOM2.WAD" "DOOM2F.WAD" "DOOM64.WAD" "TNT.WAD" IWAD_FILES=("DOOM1.WAD" "DOOM.WAD" "DOOM2.WAD" "DOOM2F.WAD" "DOOM64.WAD" "TNT.WAD"
"PLUTONIA.WAD" "HERETIC1.WAD" "HERETIC.WAD" "HEXEN.WAD" "HEXDD.WAD" "PLUTONIA.WAD" "HERETIC1.WAD" "HERETIC.WAD" "HEXEN.WAD" "HEXDD.WAD"
@ -8,16 +10,6 @@ IWAD_FILES=("DOOM1.WAD" "DOOM.WAD" "DOOM2.WAD" "DOOM2F.WAD" "DOOM64.WAD" "TNT.WA
"doom_complete.pk3" "doom_complete.pk3"
) )
# Function to log messages to terminal and a log file
log() {
local message="$1"
local logfile="$rdhome/logs/gzdoom.log"
local timestamp="$(date +[%Y-%m-%d\ %H:%M:%S])"
echo "$timestamp $message" | tee -a "$logfile"
}
# Function to check if a file is an IWAD # Function to check if a file is an IWAD
is_iwad() { is_iwad() {
local file="$1" local file="$1"
@ -62,8 +54,8 @@ if [[ "${1##*.}" != "doom" ]]; then
fi fi
# Log the command # Log the command
log "[INFO] Loading: \"$1\"" log i "Loading: \"$1\""
log "[INFO] Executing command \"$command\"" log i "Executing command \"$command\""
# Execute the command # Execute the command
eval "$command" eval "$command"
@ -71,11 +63,11 @@ if [[ "${1##*.}" != "doom" ]]; then
# Check if $1 is a .doom file # Check if $1 is a .doom file
else else
doom_file="$1" doom_file="$1"
log "[INFO] Found a doom file: \"$1\"" log i "Found a doom file: \"$1\""
# Check if the .doom file exists # Check if the .doom file exists
if [[ ! -e "$doom_file" ]]; then if [[ ! -e "$doom_file" ]]; then
log "[Error] doom file not found in \"$doom_file\"" log e "doom file not found in \"$doom_file\""
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" \
@ -103,15 +95,15 @@ else
# Check if the file is an IWAD # Check if the file is an IWAD
if [[ $(is_iwad "$found_file") == "true" ]]; then if [[ $(is_iwad "$found_file") == "true" ]]; then
command+=" -iwad $found_file" command+=" -iwad $found_file"
log "[INFO] Appending the param \"-iwad $found_file\"" log i "Appending the param \"-iwad $found_file\""
else else
command+=" -file $found_file" command+=" -file $found_file"
log "[INFO] Appending the param \"-file $found_file\"" log i "Appending the param \"-file $found_file\""
fi fi
done < "$doom_file" done < "$doom_file"
# Log the command # Log the command
log "[INFO] Executing command \"$command\"" log i "Executing command \"$command\""
# Execute the command # Execute the command
eval "$command" eval "$command"

View file

@ -15,7 +15,7 @@ save_migration() {
# ROMs on Internal # ROMs on Internal
roms_folder="$HOME/retrodeck/roms" roms_folder="$HOME/retrodeck/roms"
fi fi
echo "ROMs folder found at $roms_folder" log i "ROMs folder found at $roms_folder"
# Unhiding downloaded media from the previous versions # Unhiding downloaded media from the previous versions
if [ -d "$rdhome/.downloaded_media" ] if [ -d "$rdhome/.downloaded_media" ]
@ -74,9 +74,9 @@ save_migration() {
gamestoskip= gamestoskip=
tar -C $rdhome -czf $save_backup_file saves # Backup save directory for safety tar -C $rdhome -czf $save_backup_file saves # Backup save directory for safety
echo "Saves backed up to" $save_backup_file >> $migration_logfile log i "Saves backed up to" $save_backup_file $migration_logfile
tar -C $rdhome -czf $state_backup_file states # Backup state directory for safety tar -C $rdhome -czf $state_backup_file states # Backup state directory for safety
echo "States backed up to" $state_backup_file >> $migration_logfile log i "States backed up to" $state_backup_file $migration_logfile
( (
movefile() { # Take matching save and rom files and sort save into appropriate system folder movefile() { # Take matching save and rom files and sort save into appropriate system folder
@ -94,21 +94,22 @@ save_migration() {
gamestoskip+=("$1") gamestoskip+=("$1")
return return
fi fi
echo "INFO: Examining ROM file:" "$game" >> $migration_logfile log i "Examining ROM file:" "$game" $migration_logfile
echo "INFO: System detected as" $systemdir >> $migration_logfile log i "System detected as" $systemdir $migration_logfile
sosfile=$(sed -e "s/\^/ /g" <<< "$2") # Remove whitespace placeholder from s-ave o-r s-tate file sosfile=$(sed -e "s/\^/ /g" <<< "$2") # Remove whitespace placeholder from s-ave o-r s-tate file
sospurebasename="$(basename "$sosfile")" # Extract pure file name ie. /saves/game1.sav becomes game1 sospurebasename="$(basename "$sosfile")" # Extract pure file name ie. /saves/game1.sav becomes game1
echo "INFO: Current save or state being examined for match:" $sosfile >> $migration_logfile log i "Current save or state being examined for match:" $sosfile $migration_logfile
echo "INFO: Matching save or state" $sosfile "and game" $game "found." >> $migration_logfile log i "Matching save or state" $sosfile "and game" $game "found." $migration_logfile
echo "INFO: Moving save or state to" $current_dest_folder"/"$systemdir"/"$sosbasename >> $migration_logfile log i "Moving save or state to $current_dest_folder/$systemdir/$sosbasename" $migration_logfile
if [[ ! -d $current_dest_folder"/"$systemdir ]]; then # If system directory doesn't exist for save yet, create it if [[ ! -d $current_dest_folder"/"$systemdir ]]; then # If system directory doesn't exist for save yet, create it
echo "WARNING: Creating missing system directory" $current_dest_folder"/"$systemdir log w "Creating missing system directory $current_dest_folder/$systemdir"
mkdir $current_dest_folder/$systemdir mkdir $current_dest_folder/$systemdir
fi fi
mv "$sosfile" -t $current_dest_folder/$systemdir # Move save to appropriate system directory mv "$sosfile" -t $current_dest_folder/$systemdir # Move save to appropriate system directory
return return
else else
echo "WARNING: Game with name" "$(basename "$1" | sed -e "s/\^/ /g")" "already found. Skipping to next game..." >> $migration_logfile # Inform user of game being skipped due to duplicate ROM names local name="$(basename "$1" | sed -e "s/\^/ /g")"
log w "Game with name \"$name\" already found. Skipping to next game..." $migration_logfile # Inform user of game being skipped due to duplicate ROM names
fi fi
} }
@ -169,6 +170,6 @@ save_migration() {
fi fi
else else
echo "Version" $version "is after the save and state organization was changed, no need to sort again" log i "Version $version is after the save and state organization was changed, no need to sort again"
fi fi
} }

View file

@ -537,6 +537,6 @@ quit_retrodeck() {
start_retrodeck() { start_retrodeck() {
easter_eggs # Check if today has a surprise splashscreen and load it if so easter_eggs # Check if today has a surprise splashscreen and load it if so
# normal startup # normal startup
echo "Starting RetroDECK v$version" log i "Starting RetroDECK v$version"
emulationstation --home /var/config/emulationstation emulationstation --home /var/config/emulationstation
} }

View file

@ -118,13 +118,13 @@ fi
# If there is no config file I initalize the file with the the default values # If there is no config file I initalize the file with the the default values
if [[ ! -f "$rd_conf" ]]; then if [[ ! -f "$rd_conf" ]]; then
mkdir -p /var/config/retrodeck mkdir -p /var/config/retrodeck
echo "RetroDECK config file not found in $rd_conf" log w "RetroDECK config file not found in $rd_conf"
echo "Initializing" log i "Initializing"
# if we are here means that the we are in a new installation, so the version is valorized with the hardcoded one # if we are here means that the we are in a new installation, so the version is valorized with the hardcoded one
# Initializing the variables # Initializing the variables
if [ -z $version]; then if [ -z $version]; then
if [[ $(cat $lockfile) == *"0.4."* ]] || [[ $(cat $lockfile) == *"0.3."* ]] || [[ $(cat $lockfile) == *"0.2."* ]] || [[ $(cat $lockfile) == *"0.1."* ]]; then # If the previous version is very out of date, pre-rd_conf if [[ $(cat $lockfile) == *"0.4."* ]] || [[ $(cat $lockfile) == *"0.3."* ]] || [[ $(cat $lockfile) == *"0.2."* ]] || [[ $(cat $lockfile) == *"0.1."* ]]; then # If the previous version is very out of date, pre-rd_conf
echo "Running version workaround" log d "Running version workaround"
version=$(cat $lockfile) version=$(cat $lockfile)
else else
version="$hard_version" version="$hard_version"
@ -151,17 +151,16 @@ if [[ ! -f "$rd_conf" ]]; then
set_setting_value $rd_conf "developer_options" "true" retrodeck "options" set_setting_value $rd_conf "developer_options" "true" retrodeck "options"
fi fi
echo "Setting config file permissions" log i "Setting config file permissions"
chmod +rw $rd_conf chmod +rw $rd_conf
echo "RetroDECK config file initialized. Contents:" log i "RetroDECK config file initialized. Contents:\n"
echo log i "$(cat "$rd_conf")"
cat $rd_conf
conf_read # Load new variables into memory conf_read # Load new variables into memory
# If the config file is existing i just read the variables # If the config file is existing i just read the variables
else else
echo "Found RetroDECK config file in $rd_conf" log i "Found RetroDECK config file in $rd_conf"
echo "Loading it" log i "Loading it"
if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build
set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options" set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options"

View file

@ -1,5 +1,3 @@
#!/bin/bash
# This script provides a logging function 'log' that can be sourced in other scripts. # This script provides a logging function 'log' that can be sourced in other scripts.
# It logs messages to both the terminal and a specified logfile, allowing different log levels. # It logs messages to both the terminal and a specified logfile, allowing different log levels.
# The log function takes three parameters: log level, log message, and optionally the logfile. If no logfile is specified, it writes to retrodeck/logs/retrodeck.log # The log function takes three parameters: log level, log message, and optionally the logfile. If no logfile is specified, it writes to retrodeck/logs/retrodeck.log
@ -9,36 +7,86 @@
# log e "bar" -> logs an error with message bar in the default log file retrodeck/logs/retrodeck.log # log e "bar" -> logs an error with message bar in the default log file retrodeck/logs/retrodeck.log
# log i "par" rekku.log -> logs an information with message in the specified log file inside the logs folder retrodeck/logs/rekku.log # log i "par" rekku.log -> logs an information with message in the specified log file inside the logs folder retrodeck/logs/rekku.log
exec > >(tee -a "$logs_folder/retrodeck.log") 2>&1
log() { log() {
local level="$1" local level="$1"
local message="$2" local message="$2"
local timestamp="$(date +[%Y-%m-%d\ %H:%M:%S])" local timestamp="$(date +[%Y-%m-%d\ %H:%M:%S])"
local logfile="${3:-$logs_folder/retrodeck.log}" # Use specified logfile or default to retrodeck.log local colorize_terminal
# Use specified logfile or default to retrodeck.log
local logfile
if [ -n "$3" ]; then
logfile="$3"
else
logfile="$logs_folder/retrodeck.log"
fi
# Check if the shell is sh (not bash or zsh) to avoid colorization
if [ "${SHELL##*/}" = "sh" ]; then
colorize_terminal=false
else
colorize_terminal=true
fi
case "$level" in case "$level" in
w) w)
# Warning (yellow) for terminal, no color for log file if [ "$colorize_terminal" = true ]; then
# Warning (yellow) for terminal
colored_message="\e[33m[WARN]\e[0m $message" colored_message="\e[33m[WARN]\e[0m $message"
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile") else
# Warning (no color for sh) for terminal
colored_message="$timestamp [WARN] $message"
fi
# Write to log file without colorization
log_message="$timestamp [WARN] $message"
;; ;;
e) e)
# Error (red) for terminal, no color for log file if [ "$colorize_terminal" = true ]; then
# Error (red) for terminal
colored_message="\e[31m[ERROR]\e[0m $message" colored_message="\e[31m[ERROR]\e[0m $message"
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile") else
# Error (no color for sh) for terminal
colored_message="$timestamp [ERROR] $message"
fi
# Write to log file without colorization
log_message="$timestamp [ERROR] $message"
;; ;;
i) i)
# Info (green) for terminal, no color for log file if [ "$colorize_terminal" = true ]; then
# Info (green) for terminal
colored_message="\e[32m[INFO]\e[0m $message" colored_message="\e[32m[INFO]\e[0m $message"
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile") else
# Info (no color for sh) for terminal
colored_message="$timestamp [INFO] $message"
fi
# Write to log file without colorization
log_message="$timestamp [INFO] $message"
;; ;;
d) d)
# Debug (green) for both terminal, no color for log file if [ "$colorize_terminal" = true ]; then
# Debug (green) for terminal
colored_message="\e[32m[DEBUG]\e[0m $message" colored_message="\e[32m[DEBUG]\e[0m $message"
echo "$timestamp $colored_message" | tee -a >(sed $'s,\e\\[[0-9;]*[a-zA-Z],,g' >> "$logfile") else
# Debug (no color for sh) for terminal
colored_message="$timestamp [DEBUG] $message"
fi
# Write to log file without colorization
log_message="$timestamp [DEBUG] $message"
;; ;;
*) *)
# Default (no color) # Default (no color for other shells) for terminal
echo "$timestamp $message" | tee -a "$logfile" colored_message="$timestamp $message"
# Write to log file without colorization
log_message="$timestamp $message"
;; ;;
esac esac
# Display the message in the terminal
echo -e "$colored_message"
# Write the log message to the log file
echo "$log_message" >> "$logfile"
} }

View file

@ -89,9 +89,9 @@ prepare_emulator() {
# Shared actions # Shared actions
# PPSSPP # PPSSPP
echo "--------------------------------" log i "--------------------------------"
echo "Initializing PPSSPP_LIBRETRO" log i "Initializing PPSSPP_LIBRETRO"
echo "--------------------------------" log i "--------------------------------"
if [ -d $bios_folder/PPSSPP/flash0/font ] if [ -d $bios_folder/PPSSPP/flash0/font ]
then then
mv -fv $bios_folder/PPSSPP/flash0/font $bios_folder/PPSSPP/flash0/font.bak mv -fv $bios_folder/PPSSPP/flash0/font $bios_folder/PPSSPP/flash0/font.bak
@ -103,16 +103,16 @@ prepare_emulator() {
fi fi
# MSX / SVI / ColecoVision / SG-1000 # MSX / SVI / ColecoVision / SG-1000
echo "-----------------------------------------------------------" log i "-----------------------------------------------------------"
echo "Initializing MSX / SVI / ColecoVision / SG-1000 LIBRETRO" log i "Initializing MSX / SVI / ColecoVision / SG-1000 LIBRETRO"
echo "-----------------------------------------------------------" 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
echo "-----------------------------------------------------------" log i "-----------------------------------------------------------"
echo "Initializing AMIGA LIBRETRO" log i "Initializing AMIGA LIBRETRO"
echo "-----------------------------------------------------------" 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"
dir_prep "$texture_packs_folder/RetroArch-Mesen" "/var/config/retroarch/system/HdPacks" dir_prep "$texture_packs_folder/RetroArch-Mesen" "/var/config/retroarch/system/HdPacks"
@ -158,9 +158,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(cemu|Cemu|all)$ ]]; then if [[ "$emulator" =~ ^(cemu|Cemu|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing CEMU" log i "Initializing CEMU"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/Cemu" rm -rf "$multi_user_data_folder/$SteamAppUser/config/Cemu"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/Cemu" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/Cemu"
@ -187,9 +187,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(citra|citra-emu|Citra|all)$ ]]; then if [[ "$emulator" =~ ^(citra|citra-emu|Citra|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "------------------------" log i "------------------------"
echo "Initializing CITRA" log i "Initializing CITRA"
echo "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/citra-emu" rm -rf "$multi_user_data_folder/$SteamAppUser/config/citra-emu"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/citra-emu" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/citra-emu"
@ -234,9 +234,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(dolphin|dolphin-emu|Dolphin|all)$ ]]; then if [[ "$emulator" =~ ^(dolphin|dolphin-emu|Dolphin|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing DOLPHIN" log i "Initializing DOLPHIN"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu" rm -rf "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/dolphin-emu"
@ -289,9 +289,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(duckstation|Duckstation|all)$ ]]; then if [[ "$emulator" =~ ^(duckstation|Duckstation|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "------------------------" log i "------------------------"
echo "Initializing DUCKSTATION" log i "Initializing DUCKSTATION"
echo "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/duckstation" rm -rf "$multi_user_data_folder/$SteamAppUser/config/duckstation"
mkdir -p "$multi_user_data_folder/$SteamAppUser/data/duckstation/" mkdir -p "$multi_user_data_folder/$SteamAppUser/data/duckstation/"
@ -335,9 +335,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(melonds|melonDS|MelonDS|all)$ ]]; then if [[ "$emulator" =~ ^(melonds|melonDS|MelonDS|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing MELONDS" log i "Initializing MELONDS"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/melonDS" rm -rf "$multi_user_data_folder/$SteamAppUser/config/melonDS"
mkdir -pv "$multi_user_data_folder/$SteamAppUser/config/melonDS/" mkdir -pv "$multi_user_data_folder/$SteamAppUser/config/melonDS/"
@ -375,9 +375,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(pcsx2|PCSX2|all)$ ]]; then if [[ "$emulator" =~ ^(pcsx2|PCSX2|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing PCSX2" log i "Initializing PCSX2"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/PCSX2" rm -rf "$multi_user_data_folder/$SteamAppUser/config/PCSX2"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/PCSX2/inis"
@ -431,9 +431,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(ppsspp|PPSSPP|all)$ ]]; then if [[ "$emulator" =~ ^(ppsspp|PPSSPP|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "------------------------" log i "------------------------"
echo "Initializing PPSSPPSDL" log i "Initializing PPSSPPSDL"
echo "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/ppsspp" rm -rf "$multi_user_data_folder/$SteamAppUser/config/ppsspp"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/ppsspp/PSP/SYSTEM/"
@ -461,9 +461,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(primehack|Primehack|all)$ ]]; then if [[ "$emulator" =~ ^(primehack|Primehack|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing Primehack" log i "Initializing Primehack"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/primehack" rm -rf "$multi_user_data_folder/$SteamAppUser/config/primehack"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/primehack" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/primehack"
@ -505,9 +505,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(rpcs3|RPCS3|all)$ ]]; then if [[ "$emulator" =~ ^(rpcs3|RPCS3|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "------------------------" log i "------------------------"
echo "Initializing RPCS3" log i "Initializing RPCS3"
echo "------------------------" log i "------------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/rpcs3" rm -rf "$multi_user_data_folder/$SteamAppUser/config/rpcs3"
mkdir -pv "$multi_user_data_folder/$SteamAppUser/config/rpcs3/" mkdir -pv "$multi_user_data_folder/$SteamAppUser/config/rpcs3/"
@ -543,9 +543,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(ryujunx|Ryujinx|all)$ ]]; then if [[ "$emulator" =~ ^(ryujunx|Ryujinx|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "------------------------" log i "------------------------"
echo "Initializing RYUJINX" log i "Initializing RYUJINX"
echo "------------------------" 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"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/system" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/Ryujinx/system"
@ -570,9 +570,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(xemu|XEMU|all)$ ]]; then if [[ "$emulator" =~ ^(xemu|XEMU|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "------------------------" log i "------------------------"
echo "Initializing XEMU" log i "Initializing XEMU"
echo "------------------------" 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
rm -rf /var/data/xemu rm -rf /var/data/xemu
@ -615,9 +615,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(yuzu|Yuzu|all)$ ]]; then if [[ "$emulator" =~ ^(yuzu|Yuzu|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing YUZU" log i "Initializing YUZU"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
rm -rf "$multi_user_data_folder/$SteamAppUser/config/yuzu" rm -rf "$multi_user_data_folder/$SteamAppUser/config/yuzu"
mkdir -p "$multi_user_data_folder/$SteamAppUser/config/yuzu" mkdir -p "$multi_user_data_folder/$SteamAppUser/config/yuzu"
@ -671,11 +671,11 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(vita3k|Vita3K|all)$ ]]; then if [[ "$emulator" =~ ^(vita3k|Vita3K|all)$ ]]; then
if [[ "$action" == "reset" ]]; then # Run reset-only commands if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------" log i "----------------------"
echo "Initializing Vita3K" log i "Initializing Vita3K"
echo "----------------------" log i "----------------------"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
echo "Figure out what Vita3k needs for multi-user" log d "Figure out what Vita3k needs for multi-user"
else # Single-user actions else # Single-user actions
# NOTE: the emulator is writing in "." so it must be placed in the rw filesystem. A symlink of the binary is already placed in /app/bin/Vita3K # NOTE: the emulator is writing in "." so it must be placed in the rw filesystem. A symlink of the binary is already placed in /app/bin/Vita3K
rm -rf "/var/data/Vita3K" rm -rf "/var/data/Vita3K"
@ -706,9 +706,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(mame|MAME|all)$ ]]; then if [[ "$emulator" =~ ^(mame|MAME|all)$ ]]; then
# 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
echo "----------------------" log i "----------------------"
echo "Initializing MAME" log i "Initializing MAME"
echo "----------------------" log i "----------------------"
mkdir -p $saves_folder/mame-sa mkdir -p $saves_folder/mame-sa
mkdir -p "/var/config/mame" mkdir -p "/var/config/mame"
@ -723,9 +723,9 @@ prepare_emulator() {
if [[ "$emulator" =~ ^(gzdoom|GZDOOM|all)$ ]]; then if [[ "$emulator" =~ ^(gzdoom|GZDOOM|all)$ ]]; then
# 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
echo "----------------------" log i "----------------------"
echo "Initializing GZDOOM" log i "Initializing GZDOOM"
echo "----------------------" log i "----------------------"
mkdir -p "/var/config/gzdoom" mkdir -p "/var/config/gzdoom"
mkdir -p "/var/data/gzdoom" mkdir -p "/var/data/gzdoom"

View file

@ -118,7 +118,7 @@ done
if [ -f "$lockfile" ]; then if [ -f "$lockfile" ]; then
# ...but the version doesn't match with the config file # ...but the version doesn't match with the config file
if [ "$hard_version" != "$version" ]; then if [ "$hard_version" != "$version" ]; then
echo "Config file's version is $version but the actual version is $hard_version" log i "Config file's version is $version but the actual version is $hard_version"
if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build
configurator_generic_dialog "RetroDECK Cooker Warning" "RUNNING COOKER VERSIONS OF RETRODECK CAN BE EXTREMELY DANGEROUS AND ALL OF YOUR RETRODECK DATA\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\nARE AT RISK BY CONTINUING!" configurator_generic_dialog "RetroDECK Cooker Warning" "RUNNING COOKER VERSIONS OF RETRODECK CAN BE EXTREMELY DANGEROUS AND ALL OF YOUR RETRODECK DATA\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\nARE AT RISK BY CONTINUING!"
set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options" set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options"
@ -132,7 +132,7 @@ if [ -f "$lockfile" ]; then
rc=$? # Capture return code, as "Yes" button has no text value rc=$? # Capture return code, as "Yes" button has no text value
if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked
if [[ $choice == "Don't Upgrade" ]]; then # If user wants to bypass the post_update.sh process this time. if [[ $choice == "Don't Upgrade" ]]; then # If user wants to bypass the post_update.sh process this time.
echo "Skipping upgrade process for cooker build, updating stored version in retrodeck.cfg" log i "Skipping upgrade process for cooker build, updating stored version in retrodeck.cfg"
set_setting_value $rd_conf "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg set_setting_value $rd_conf "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg
elif [[ $choice == "Full Wipe and Fresh Install" ]]; then # Remove all RetroDECK data and start a fresh install elif [[ $choice == "Full Wipe and Fresh Install" ]]; then # Remove all RetroDECK data and start a fresh install
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "This is going to remove all of the data in all locations used by RetroDECK!\n\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\n\nAre you sure you want to contine?") == "true" ]]; then if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "This is going to remove all of the data in all locations used by RetroDECK!\n\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\n\nAre you sure you want to contine?") == "true" ]]; then
@ -140,7 +140,7 @@ if [ -f "$lockfile" ]; then
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "But are you super DUPER sure? We REAAAALLLLLYY want to make sure you know what is happening here.\n\nThe ~/retrodeck and ~/.var/app/net.retrodeck.retrodeck folders and ALL of their contents\nare about to be PERMANENTLY removed.\n\nStill sure you want to proceed?") == "true" ]]; then if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "But are you super DUPER sure? We REAAAALLLLLYY want to make sure you know what is happening here.\n\nThe ~/retrodeck and ~/.var/app/net.retrodeck.retrodeck folders and ALL of their contents\nare about to be PERMANENTLY removed.\n\nStill sure you want to proceed?") == "true" ]]; then
configurator_generic_dialog "RetroDECK Cooker Reset" "Ok, if you're that sure, here we go!" configurator_generic_dialog "RetroDECK Cooker Reset" "Ok, if you're that sure, here we go!"
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "(Are you actually being serious here? Because we are...\n\nNo backsies.)") == "true" ]]; then if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "(Are you actually being serious here? Because we are...\n\nNo backsies.)") == "true" ]]; then
echo "Removing RetroDECK data and starting fresh" log w "Removing RetroDECK data and starting fresh"
rm -rf /var rm -rf /var
rm -rf "$HOME/retrodeck" rm -rf "$HOME/retrodeck"
source /app/libexec/global.sh source /app/libexec/global.sh
@ -151,7 +151,7 @@ if [ -f "$lockfile" ]; then
fi fi
fi fi
else else
echo "Performing normal upgrade process for version" $cooker_base_version log i "Performing normal upgrade process for version" $cooker_base_version
version=$cooker_base_version # Temporarily assign cooker base version to $version so update script can read it properly. version=$cooker_base_version # Temporarily assign cooker base version to $version so update script can read it properly.
post_update post_update
fi fi
@ -170,7 +170,7 @@ if [ -f "$lockfile" ]; then
# Else, LOCKFILE IS NOT EXISTING (WAS REMOVED) # Else, LOCKFILE IS NOT EXISTING (WAS REMOVED)
# if the lock file doesn't exist at all means that it's a fresh install or a triggered reset # if the lock file doesn't exist at all means that it's a fresh install or a triggered reset
else else
echo "Lockfile not found" log w "Lockfile not found"
finit # Executing First/Force init finit # Executing First/Force init
fi fi

View file

@ -8,7 +8,7 @@ source /app/libexec/logger.sh
# Check if a function was specified # Check if a function was specified
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
echo "Usage: $0 function_name [args...]" log e "Usage: $0 function_name [args...]"
exit 1 exit 1
fi fi
@ -18,7 +18,7 @@ shift
# Check if the function exists # Check if the function exists
if ! declare -f "$function_name" >/dev/null 2>&1; then if ! declare -f "$function_name" >/dev/null 2>&1; then
echo "Function '$function_name' not found" log e "Function \'$function_name\' not found"
exit 1 exit 1
fi fi