2022-03-27 13:30:22 +00:00
#!/bin/bash
2022-10-06 21:47:09 +00:00
# workaround to fix a bug when updating to 0.5.0b where the post update is not triggered
# basically from 0.5 it's not reading the version from the lockfile so it doesn't know from which version it came from and the new rule of global.sh is that if version is unknown it's like a first boot
# remove it in the future
lockfile = "/var/config/retrodeck/.lock"
if [ [ $( cat $lockfile ) = = *"0.4." * ] ] || [ [ $( cat $lockfile ) = = *"0.3." * ] ] || [ [ $( cat $lockfile ) = = *"0.2." * ] ] || [ [ $( cat $lockfile ) = = *"0.1." * ] ]
then
echo "Running version workaround"
version = $( cat $lockfile )
fi
2022-07-23 18:19:03 +00:00
source /app/bin/global.sh
2022-03-30 14:14:43 +00:00
2022-07-10 19:48:19 +00:00
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
if [ -f " $HOME /retrodeck/.lock " ]
then
mv " $HOME /retrodeck/.lock " $lockfile
fi
2022-05-19 14:30:43 +00:00
# Functions area
dir_prep( ) {
# This script is creating a symlink preserving old folder contents and moving them in the new one
2022-10-13 12:21:30 +00:00
2022-05-19 14:30:43 +00:00
# Call me with:
# dir prep "real dir" "symlink location"
real = " $1 "
symlink = " $2 "
2022-06-16 09:13:07 +00:00
echo -e " \n[DIR PREP]\nMoving $symlink in $real " #DEBUG
2022-05-19 14:30:43 +00:00
# if the dest dir exists we want to backup it
if [ -d " $symlink " ] ;
then
echo " $symlink found " #DEBUG
mv -fv " $symlink " " $symlink .old "
fi
# if the real dir doesn't exist we create it
if [ ! -d " $real " ] ;
then
echo " $real not found, creating it " #DEBUG
mkdir -pv " $real "
fi
2022-10-13 12:21:30 +00:00
2022-05-19 14:30:43 +00:00
# creating the symlink
echo " linking $real in $symlink " #DEBUG
2022-05-20 05:41:46 +00:00
mkdir -pv " $( dirname " $symlink " ) " # creating the full path except the last folder
2022-07-20 07:51:56 +00:00
ln -svf " $real " " $symlink "
2022-05-19 14:30:43 +00:00
# moving everything from the old folder to the new one, delete the old one
if [ -d " $symlink .old " ] ;
then
echo " Moving the data from $symlink .old to $real " #DEBUG
2022-06-08 10:13:43 +00:00
mv -fv " $symlink " .old/* $real
2022-05-19 14:30:43 +00:00
echo " Removing $symlink .old " #DEBUG
rm -rf " $symlink .old "
fi
2022-06-16 09:13:07 +00:00
echo -e " $symlink is now $real \n "
2022-05-19 14:30:43 +00:00
}
2022-05-11 11:43:15 +00:00
2022-05-19 14:30:43 +00:00
tools_init( ) {
rm -rfv /var/config/retrodeck/tools/
mkdir -pv /var/config/retrodeck/tools/
2022-10-04 13:29:12 +00:00
cp -rfv /app/retrodeck/tools/* /var/config/retrodeck/tools/
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/emulationstation/.emulationstation/custom_systems/tools/
2022-10-04 13:29:12 +00:00
rm -rfv /var/config/retrodeck/tools/gamelist.xml
cp -fv /app/retrodeck/tools-gamelist.xml /var/config/retrodeck/tools/gamelist.xml
2022-05-19 14:30:43 +00:00
}
standalones_init( ) {
# This script is configuring the standalone emulators with the default files present in emuconfigs folder
2022-10-13 12:21:30 +00:00
2022-06-16 09:13:07 +00:00
echo "----------------------"
2022-05-19 14:30:43 +00:00
echo "Initializing standalone emulators"
2022-06-16 09:13:07 +00:00
echo "----------------------"
2022-05-19 14:30:43 +00:00
# Yuzu
2022-06-16 09:13:07 +00:00
echo "----------------------"
echo "Initializing YUZU"
echo "----------------------"
2022-05-19 14:30:43 +00:00
# removing dead symlinks as they were present in a past version
if [ -d $rdhome /bios/switch ] ; then
find $rdhome /bios/switch -xtype l -exec rm { } \;
fi
# initializing the keys folder
dir_prep " $rdhome /bios/switch/keys " "/var/data/yuzu/keys"
# initializing the firmware folder
2022-05-22 08:03:30 +00:00
dir_prep " $rdhome /bios/switch/registered " "/var/data/yuzu/nand/system/Contents/registered"
2022-10-13 23:55:20 +00:00
# initializing the save folders
dir_prep " $rdhome /saves/switch/yuzu/nand " "/var/data/yuzu/nand"
dir_prep " $rdhome /saves/switch/yuzy/sdmc " "/var/data/yuzu/sdmc"
2022-05-19 14:30:43 +00:00
# configuring Yuzu
2022-09-11 21:41:51 +00:00
dir_prep " $rdhome /.logs/yuzu " "/var/data/yuzu/log"
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/yuzu/
2022-07-10 10:08:41 +00:00
cp -fvr $emuconfigs /yuzu/* /var/config/yuzu/
2022-06-08 12:42:36 +00:00
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/yuzu/qt-config.ini
2022-06-01 20:57:37 +00:00
dir_prep " $rdhome /screenshots " "/var/data/yuzu/screenshots"
2022-05-19 14:30:43 +00:00
# Dolphin
2022-06-16 09:13:07 +00:00
echo "----------------------"
echo "Initializing DOLPHIN"
echo "----------------------"
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/dolphin-emu/
2022-07-10 10:08:41 +00:00
cp -fvr " $emuconfigs /dolphin/ " * /var/config/dolphin-emu/
2022-09-08 15:45:57 +00:00
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/dolphin-emu/Dolphin.ini
2022-09-10 18:45:35 +00:00
dir_prep " $rdhome /saves/gc/dolphin/EUR " "/var/data/dolphin-emu/GC/EUR"
dir_prep " $rdhome /saves/gc/dolphin/USA " "/var/data/dolphin-emu/GC/USA"
dir_prep " $rdhome /saves/gc/dolphin/JAP " "/var/data/dolphin-emu/GC/JAP"
dir_prep " $rdhome /screenshots " "/var/data/dolphin-emu/ScreenShots"
dir_prep " $rdhome /states " "/var/data/dolphin-emu/StateSaves"
dir_prep " $rdhome /saves/wii/dolphin " "/var/data/dolphin-emu/Wii/"
2022-05-19 14:30:43 +00:00
# pcsx2
2022-06-16 09:13:07 +00:00
echo "----------------------"
echo "Initializing PCSX2"
echo "----------------------"
2022-10-11 09:21:38 +00:00
mkdir -pv "/var/config/PCSX2/inis"
2022-09-11 20:55:00 +00:00
mkdir -pv " $rdhome /saves/ps2/pcsx2/memcards "
2022-10-11 09:21:38 +00:00
mkdir -pv " $rdhome /states/ps2/pcsx2 "
2022-09-07 18:52:36 +00:00
cp -fvr $emuconfigs /PCSX2/* /var/config/PCSX2/inis/
2022-06-08 12:42:36 +00:00
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/PCSX2/inis/PCSX2_ui.ini
2022-09-07 18:52:36 +00:00
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/PCSX2/inis/PCSX2.ini
2022-10-11 09:21:38 +00:00
#dir_prep "$rdhome/states/ps2/pcsx2" "/var/config/PCSX2/sstates"
#dir_prep "$rdhome/screenshots" "/var/config/PCSX2/snaps"
#dir_prep "$rdhome/.logs" "/var/config/PCSX2/logs"
#dir_prep "$rdhome/bios" "$rdhome/bios/pcsx2"
2022-05-19 14:30:43 +00:00
# MelonDS
2022-06-16 09:13:07 +00:00
echo "----------------------"
echo "Initializing MELONDS"
echo "----------------------"
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/melonDS/
2022-09-11 20:55:00 +00:00
mkdir -pv " $rdhome /saves/nds/melonds "
mkdir -pv " $rdhome /states/nds/melonds "
2022-05-19 14:30:43 +00:00
dir_prep " $rdhome /bios " "/var/config/melonDS/bios"
2022-06-16 09:13:07 +00:00
cp -fvr $emuconfigs /melonDS.ini /var/config/melonDS/
2022-06-08 12:25:58 +00:00
# Replace ~/retrodeck with $rdhome as ~ cannot be understood by MelonDS
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/melonDS/melonDS.ini
2022-05-19 14:30:43 +00:00
# CITRA
2022-07-21 18:40:44 +00:00
echo "------------------------"
2022-06-16 09:13:07 +00:00
echo "Initializing CITRA"
2022-07-21 18:40:44 +00:00
echo "------------------------"
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/citra-emu/
2022-09-11 20:55:00 +00:00
mkdir -pv " $rdhome /saves/n3ds/citra/nand/ "
mkdir -pv " $rdhome /saves/n3ds/citra/sdmc/ "
2022-10-13 20:51:27 +00:00
dir_prep " $rdhome /bios/citra/sysdata " "/var/data/citra-emu/sysdata"
2022-09-11 21:41:51 +00:00
dir_prep " $rdhome /.logs/citra " "/var/data/citra-emu/log"
2022-05-19 14:30:43 +00:00
cp -fv $emuconfigs /citra-qt-config.ini /var/config/citra-emu/qt-config.ini
2022-06-30 08:01:29 +00:00
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/citra-emu/qt-config.ini
#TODO: do the same with roms folders after new variables is pushed (check even the others qt-emu)
#But actually everything is always symlinked to retrodeck/roms so it might be not needed
#sed -i 's#~/retrodeck#'$rdhome'#g' /var/config/citra-emu/qt-config.ini
2022-05-19 14:30:43 +00:00
# RPCS3
2022-07-21 18:40:44 +00:00
echo "------------------------"
2022-06-16 09:13:07 +00:00
echo "Initializing RPCS3"
2022-07-21 18:40:44 +00:00
echo "------------------------"
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/rpcs3/
2022-09-27 13:51:36 +00:00
cp -fvr $emuconfigs /rpcs3/* /var/config/rpcs3/
sed -i 's#/home/deck/retrodeck#' $rdhome '#g' /var/config/rpcs3/vfs.yml
2022-05-19 14:30:43 +00:00
2022-07-22 17:23:38 +00:00
# XEMU
echo "------------------------"
echo "Initializing XEMU"
echo "------------------------"
2022-09-27 16:01:38 +00:00
mkdir -pv $rdhome /saves/xbox/xemu/
2022-07-22 17:23:38 +00:00
cp -fv $emuconfigs /xemu.toml /var/data/xemu/xemu.toml
sed -i 's#/home/deck/retrodeck#' $rdhome '#g' /var/data/xemu/xemu.toml
# Preparing HD dummy Image if the image is not found
if [ ! -f $rdhome /bios/xbox_hdd.qcow2 ]
then
wget "https://github.com/mborgerson/xemu-hdd-image/releases/latest/download/xbox_hdd.qcow2.zip" -P $rdhome /bios/
unzip $rdhome /bios/xbox_hdd.qcow2.zip $rdhome /bios/
rm -rfv $rdhome /bios/xbox_hdd.qcow2.zip
fi
# PPSSPPSDL
echo "------------------------"
echo "Initializing PPSSPPSDL"
echo "------------------------"
mkdir -p /var/config/ppsspp/PSP/SYSTEM/
cp -fv $emuconfigs /ppssppsdl/* /var/config/ppsspp/PSP/SYSTEM/
sed -i 's#/home/deck/retrodeck#' $rdhome '#g' /var/config/ppsspp/PSP/SYSTEM/ppsspp.ini
2022-09-24 18:28:49 +00:00
# DUCKSTATION
2022-09-05 18:49:54 +00:00
echo "------------------------"
echo "Initializing DUCKSTATION"
echo "------------------------"
mkdir -p /var/config/duckstation/
cp -fv $emuconfigs /duckstation/* /var/config/duckstation
sed -i 's#/home/deck/retrodeck/bios#' $rdhome /bios'#g' /var/config/ppsspp/PSP/SYSTEM/settings.ini
2022-05-19 14:30:43 +00:00
# PICO-8
2022-05-20 06:37:43 +00:00
# Moved PICO-8 stuff in the finit as only it knows here roms folders is
2022-05-19 14:30:43 +00:00
}
ra_init( ) {
dir_prep " $rdhome /bios " "/var/config/retroarch/system"
2022-09-29 21:26:02 +00:00
dir_prep " $rdhome /.logs/retroarch " "/var/config/retroarch/logs"
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/retroarch/cores/
cp /app/share/libretro/cores/* /var/config/retroarch/cores/
2022-07-21 18:52:53 +00:00
cp -fv $emuconfigs /retroarch.cfg /var/config/retroarch/
2022-10-14 14:43:11 +00:00
if [ $overwrite_configs = true ] ; then
2022-07-21 18:52:53 +00:00
cp -fv $emuconfigs /retroarch-core-options.cfg /var/config/retroarch/
2022-06-08 12:42:36 +00:00
sed -i 's#~/retrodeck#' $rdhome '#g' /var/config/retroarch/retroarch.cfg
2022-10-14 14:21:08 +00:00
fi
#rm -rf $rdhome/bios/bios # in some situations a double bios symlink is created
2022-07-21 18:40:44 +00:00
# PPSSPP
echo "--------------------------------"
echo "Initializing PPSSPP_LIBRETRO"
echo "--------------------------------"
if [ -d $rdhome /bios/PPSSPP/flash0/font ]
then
2022-07-21 18:52:53 +00:00
mv -fv $rdhome /bios/PPSSPP/flash0/font $rdhome /bios/PPSSPP/flash0/font.bak
2022-07-21 18:40:44 +00:00
fi
2022-07-21 18:52:53 +00:00
mkdir -p $rdhome /bios/PPSSPP
2022-07-25 19:01:45 +00:00
#if [ ! -f "$rdhome/bios/PPSSPP/ppge_atlas.zim" ]
#then
2022-07-23 18:19:03 +00:00
wget "https://github.com/hrydgard/ppsspp/archive/refs/heads/master.zip" -P $rdhome /bios/PPSSPP
unzip " $rdhome /bios/PPSSPP/master.zip " -d $rdhome /bios/PPSSPP/
2022-07-25 19:01:45 +00:00
mv " $rdhome /bios/PPSSPP/ppsspp-master/assets/ " * " $rdhome /bios/PPSSPP/ "
2022-07-23 18:19:03 +00:00
rm -rfv " $rdhome /bios/PPSSPP/master.zip "
rm -rfv " $rdhome /bios/PPSSPP/ppsspp-master "
2022-07-25 19:01:45 +00:00
#fi
2022-07-21 18:40:44 +00:00
if [ -d $rdhome /bios/PPSSPP/flash0/font.bak ]
then
2022-07-21 18:52:53 +00:00
mv -fv $rdhome /bios/PPSSPP/flash0/font.bak $rdhome /bios/PPSSPP/flash0/font
2022-07-21 18:40:44 +00:00
fi
2022-07-23 09:36:57 +00:00
2022-07-21 18:40:44 +00:00
2022-07-21 18:52:53 +00:00
# MSX / SVI / ColecoVision / SG-1000
echo "-----------------------------------------------------------"
echo "Initializing MSX / SVI / ColecoVision / SG-1000 LIBRETRO"
echo "-----------------------------------------------------------"
wget "http://bluemsx.msxblue.com/rel_download/blueMSXv282full.zip" -P $rdhome /bios/MSX
unzip " $rdhome /bios/MSX/blueMSXv282full.zip " $rdhome /bios/MSX
mv -rfv $rdhome /bios/MSX/Databases $rdhome /bios/Databases
mv -rfv $rdhome /bios/MSX/Machines $rdhome /bios/Machines
rm -rfv $rdhome /bios/MSX
2022-05-19 14:30:43 +00:00
}
create_lock( ) {
2022-09-06 12:46:59 +00:00
# creating RetroDECK's lock file and writing the version in the config file
2022-09-10 15:47:53 +00:00
version = $hard_version
2022-09-06 12:46:59 +00:00
touch " $lockfile "
2022-09-05 18:16:14 +00:00
conf_write
2022-05-19 14:30:43 +00:00
}
post_update( ) {
# post update script
echo "Executing post-update script"
2022-10-07 22:50:36 +00:00
# Finding existing ROMs folder
if [ -d " $default_sd /retrodeck " ]
then
# ROMs on SD card
roms_folder = " $default_sd /retrodeck/roms "
else
# ROMs on Internal
roms_folder = " $HOME /retrodeck/roms "
fi
echo " ROMs folder found at $roms_folder "
2022-07-10 19:48:19 +00:00
# Unhiding downloaded media from the previous versions
if [ -d " $rdhome /.downloaded_media " ]
then
2022-07-27 09:20:38 +00:00
mv -fv " $rdhome /.downloaded_media " " $media_folder "
2022-07-10 19:48:19 +00:00
fi
# Unhiding themes folder from the previous versions
if [ -d " $rdhome /.themes " ]
2022-07-10 19:41:37 +00:00
then
2022-07-27 09:20:38 +00:00
mv -fv " $rdhome /.themes " " $themes_folder "
2022-07-10 19:41:37 +00:00
fi
2022-07-27 09:20:38 +00:00
# Doing the dir prep as we don't know from which version we came
dir_prep " $media_folder " "/var/config/emulationstation/.emulationstation/downloaded_media"
dir_prep " $themes_folder " "/var/config/emulationstation/.emulationstation/themes"
2022-05-21 13:25:06 +00:00
mkdir -pv $rdhome /.logs #this was added later, maybe safe to remove in a few versions
2022-10-13 12:21:30 +00:00
2022-07-10 19:48:19 +00:00
2022-10-04 13:51:30 +00:00
# Resetting es_settings, now we need it but in the future I should think a better solution, maybe with sed
2022-07-10 19:48:19 +00:00
cp -fv /app/retrodeck/es_settings.xml /var/config/emulationstation/.emulationstation/es_settings.xml
2022-09-27 15:55:30 +00:00
2022-10-01 21:07:13 +00:00
# 0.4 -> 0.5
2022-10-01 15:44:12 +00:00
# Perform save and state migration if needed
2022-10-14 14:21:08 +00:00
# Moving PCSX2 Saves if needed
if [ [ -d /var/config/PCSX2 ] ] ; then
mv -fv /var/config/PCSX2/sstates/* $rdhome /states/ps2/pcsx2
mv -fv /var/config/PCSX2/memcards/* $rdhome /saves/ps2/memcards
fi
2022-10-13 12:21:30 +00:00
2022-10-14 14:21:08 +00:00
# Moving Citra saves from legacy location to 0.5.0b structure if needed
if [ [ -d $rdhome /saves/Citra ] ] ; then
2022-10-13 12:21:30 +00:00
mv -fv $rdhome /saves/Citra/* $rdhome /saves/n3ds/citra
rmdir $rdhome /saves/Citra # Old folder cleanup
2022-10-14 14:21:08 +00:00
fi
2022-10-13 12:21:30 +00:00
2022-09-29 21:26:02 +00:00
versionwheresaveschanged = "0.4.5b" # Hardcoded break point between unsorted and sorted saves
2022-10-14 14:21:08 +00:00
if [ [ $( sed -e "s/\.//g" <<< $hard_version ) > $( sed -e "s/\.//g" <<< $versionwheresaveschanged ) ] ] && [ [ ! $( sed -e "s/\.//g" <<< $version ) > $( sed -e "s/\.//g" <<< $versionwheresaveschanged ) ] ] ; then # Check if user is upgrading from the version where save organization was changed. Try not to reuse this, it things 0.4.5b is newer than 0.4.5
2022-09-29 21:26:02 +00:00
migration_logfile = $rdhome /.logs/savemove_" $( date +"%Y_%m_%d_%I_%M_%p" ) .log "
save_backup_file = $rdhome /savebackup_" $( date +"%Y_%m_%d_%I_%M_%p" ) .zip "
state_backup_file = $rdhome /statesbackup_" $( date +"%Y_%m_%d_%I_%M_%p" ) .zip "
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \
2022-10-08 13:55:12 +00:00
--text= "You are updating to a version of RetroDECK where save file locations have changed!\n\nYour existing files will be backed up for safety and then sorted automatically.\n\nIf a file cannot be sorted automatically it will remain where it is for manual sorting.\n\nPLEASE BE PATIENT! This process can take several minutes if you have a large ROM library."
2022-09-29 21:26:02 +00:00
2022-10-07 13:28:27 +00:00
allgames = ( $( find " $roms_folder " -maxdepth 2 -mindepth 2 ! -name "systeminfo.txt" ! -name "systems.txt" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" ! -name "*^*" | sed -e "s/ /\^/g" ) ) # Build an array of all games and multi-disc-game-containing folders, adding whitespace placeholder
2022-09-29 21:26:02 +00:00
2022-10-07 13:28:27 +00:00
allsaves = ( $( find " $saves_folder " -mindepth 1 -maxdepth 1 -name "*.*" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" | sed -e "s/ /\^/g" ) ) # Build an array of all save files, ignoring standalone emulator sub-folders, adding whitespace placeholder
2022-09-29 21:26:02 +00:00
2022-10-07 13:28:27 +00:00
allstates = ( $( find " $states_folder " -mindepth 1 -maxdepth 1 -name "*.*" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" | sed -e "s/ /\^/g" ) ) # Build an array of all state files, ignoring standalone emulator sub-folders, adding whitespace placeholder
2022-09-29 21:26:02 +00:00
totalsaves = ${# allsaves [@] }
totalstates = ${# allstates [@] }
filesleft =
current_dest_folder =
gamestoskip =
tar -C $rdhome -czf $save_backup_file saves # Backup save directory for safety
echo "Saves backed up to" $save_backup_file >> $migration_logfile
tar -C $rdhome -czf $state_backup_file states # Backup state directory for safety
echo "States backed up to" $state_backup_file >> $migration_logfile
(
movefile( ) { # Take matching save and rom files and sort save into appropriate system folder
2022-10-01 15:44:12 +00:00
echo " # $filesleft $currentlybeingmoved remaining... " # These lines update the Zenity progress bar
2022-09-29 21:26:02 +00:00
progress = $(( 100 - ( ( 100 / " $totalfiles " ) * " $filesleft " )) )
echo $progress
filesleft = $(( filesleft-1))
if [ [ ! " ${ gamestoskip [*] } " = ~ " ${ 1 } " ] ] ; then # If the current game name exists multiple times in array ie. /roms/snes/Mortal Kombat 3.zip and /roms/genesis/Mortal Kombat 3.zip, skip and alert user to sort manually
game = $( sed -e "s/\^/ /g" <<< " $1 " ) # Remove whitespace placeholder
gamebasename = $( basename " $game " | sed -e 's/\..*//' ) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
systemdir = " $( basename " $( dirname " $1 " ) " ) " # Extract parent directory identifying system ROM belongs to
matches = ( $( find " $roms_folder " -maxdepth 2 -mindepth 2 -name " $gamebasename " ".*" | sed -e 's/ /^/g' | sed -e 's/\..*//' ) ) # Search for multiple instances of pure game name, adding to skip list if found
if [ [ ${# matches [@] } -gt 1 ] ] ; then
echo "ERROR: Multiple ROMS found with name:" $gamebasename "Please sort saves and states for these ROMS manually" >> $migration_logfile
gamestoskip += ( " $1 " )
return
fi
echo "INFO: Examining ROM file:" " $game " >> $migration_logfile
echo "INFO: System detected as" $systemdir >> $migration_logfile
sosfile = $( sed -e "s/\^/ /g" <<< " $2 " ) # Remove whitespace placeholder from s-ave o-r s-tate file
2022-10-01 15:44:12 +00:00
sospurebasename = " $( basename " $sosfile " ) " # Extract pure file name ie. /saves/game1.sav becomes game1
2022-09-29 21:26:02 +00:00
echo "INFO: Current save or state being examined for match:" $sosfile >> $migration_logfile
echo "INFO: 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
if [ [ ! -d $current_dest_folder "/" $systemdir ] ] ; then # If system directory doesn't exist for save yet, create it
2022-10-01 15:44:12 +00:00
echo "WARNING: Creating missing system directory" $current_dest_folder "/" $systemdir
mkdir $current_dest_folder /$systemdir
2022-09-29 21:26:02 +00:00
fi
2022-10-01 15:44:12 +00:00
mv " $sosfile " -t $current_dest_folder /$systemdir # Move save to appropriate system directory
return
2022-09-29 21:26:02 +00:00
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
fi
}
find " $roms_folder " -mindepth 2 -maxdepth 2 -name "*\^*" -exec echo "ERROR: Game named" { } "found, please move save manually" \; >> $migration_logfile # Warn user if any of their files have the whitespace replacement character used by the script
totalfiles = $totalsaves #set variables for save file migration
2022-10-01 15:44:12 +00:00
filesleft = $totalsaves
currentlybeingmoved = "saves"
2022-09-29 21:26:02 +00:00
current_dest_folder = $saves_folder
for i in " ${ allsaves [@] } " ; do # For each save file, compare to every ROM file name looking for a match
found =
currentsave = ( $( basename " $i " | sed -e 's/\..*//' ) ) # Extract pure file name ie. /saves/game1.sav becomes game1
for j in " ${ allgames [@] } " ; do
currentgame = ( $( basename " $j " | sed -e 's/\..*//' ) ) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
[ [ $currentgame = = $currentsave ] ] && { found = 1; break; } # If names match move to next stage, otherwise skip
done
[ [ -n $found ] ] && movefile $j $i || echo "ERROR: No ROM match found for save file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded save file
done
totalfiles = $totalstates #set variables for state file migration
2022-10-01 15:44:12 +00:00
filesleft = $totalstates
currentlybeingmoved = "states"
2022-09-29 21:26:02 +00:00
current_dest_folder = $states_folder
for i in " ${ allstates [@] } " ; do # For each state file, compare to every ROM file name looking for a match
found =
currentstate = ( $( basename " $i " | sed -e 's/\..*//' ) ) # Extract pure file name ie. /states/game1.sav becomes game1
for j in " ${ allgames [@] } " ; do
currentgame = ( $( basename " $j " | sed -e 's/\..*//' ) ) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
[ [ $currentgame = = $currentstate ] ] && { found = 1; break; } # If names match move to next stage, otherwise skip
done
[ [ -n $found ] ] && movefile $j $i || echo "ERROR: No ROM match found for state file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded state file
done
2022-10-13 12:21:30 +00:00
) |
2022-09-29 21:26:02 +00:00
zenity --progress \
--icon-name= net.retrodeck.retrodeck \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title= "Processing Files" \
--text= "# files remaining..." \
--percentage= 0 \
--no-cancel \
--auto-close
2022-10-08 13:55:12 +00:00
if [ [ $( cat $migration_logfile | grep "ERROR" | wc -l) -eq 0 ] ] ; then
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \
--text= "The migration process has sorted all of your files automatically.\n\nEverything should be working normally, if you experience any issues please check the RetroDECK wiki or contact us directly on the Discord."
else
cat $migration_logfile | grep "ERROR" > " $rdhome /manual_sort_needed.log "
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \
--text= " The migration process was unable to sort $( cat $migration_logfile | grep "ERROR" | wc -l) files automatically.\n\nThese files will need to be moved manually to their new locations, find more detail on the RetroDECK wiki.\n\nA log of the files that need manual sorting can be found at $rdhome /manual_sort_needed.log "
fi
2022-09-29 21:26:02 +00:00
else
echo "Version" $version "is after the save and state organization was changed, no need to sort again"
fi
2022-10-14 14:21:08 +00:00
if [ [ $( sed -e "s/\.//g" <<< $hard_version ) > $( sed -e "s/\.//g" <<< $versionwheresaveschanged ) ] ] && [ [ ! $( sed -e "s/\.//g" <<< $version ) > $( sed -e "s/\.//g" <<< $versionwheresaveschanged ) ] ] ; then # Check if user is upgrading from the version where save organization was changed.
overwrite_configs = true
fi
2022-10-14 14:31:23 +00:00
(
2022-05-19 14:30:43 +00:00
ra_init
standalones_init
tools_init
2022-10-14 14:31:23 +00:00
) |
zenity --progress --pulsate \
--icon-name= net.retrodeck.retrodeck \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title= "Finishing upgrade" \
--text= "Finishing upgrade, please wait." \
--no-cancel \
--auto-close
2022-05-19 14:30:43 +00:00
create_lock
2022-10-14 14:21:08 +00:00
overwrite_configs = false
2022-05-19 14:30:43 +00:00
}
start_retrodeck( ) {
# normal startup
echo " Starting RetroDECK v $version "
emulationstation --home /var/config/emulationstation
}
2022-07-23 18:19:03 +00:00
browse( ) {
2022-07-27 09:20:38 +00:00
# Function for browsing the sd card
2022-07-23 18:19:03 +00:00
path_selected = false
while [ $path_selected = = false ]
do
2022-10-13 12:21:30 +00:00
sdcard = " $( zenity --file-selection --title= "Choose retrodeck folder location" --directory) "
2022-07-23 18:19:03 +00:00
echo " Path choosed: $sdcard , answer= $? "
zenity --question --no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" \
--cancel-label= "No" \
--ok-label "Yes" \
--text= " Your rom folder will be:\n\n $sdcard /retrodeck/roms\n\nis that ok? "
if [ $? = = 0 ] #yes
then
sdselected = = true
roms_folder = " $sdcard /retrodeck/roms "
break
else
zenity --question --no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label= "No" --ok-label "Yes" --text= "Do you want to quit?"
if [ $? = = 0 ] # yes, quit
then
exit 0
fi
fi
done
}
2022-09-24 18:28:49 +00:00
#advanced(){
# # function to give advanced install options
# echo "Advaced choosed"
#
# choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
# --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" \
# --ok-label "ROMs" \
# --extra-button "Media" \
# --extra-button "Themes" \
# --extra-button "Back" \
# --text="What do you want to change?\n\nROMS folder = $roms_folder\nMedia folder (scraped data) = $media_folder\nThemes folder=$themes_folder" )
# echo "Choice is $choice"
#
# case $choice in
#
# "" ) # Internal (yes)
# echo "ROMs"
# ;;
#
# "Media" )
# echo "Media"
# ;;
#
# "Themes" )
# echo "Themes"
# ;;
#
# "Back" ) # Browse + not found fallback
# echo "Back"
# finit
# ;;
#
# esac
#}
2022-07-27 09:20:38 +00:00
2022-05-19 14:30:43 +00:00
finit( ) {
# Force/First init, depending on the situation
echo "Executing finit"
# Internal or SD Card?
2022-07-22 17:08:10 +00:00
choice = $( zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" \
2022-09-24 18:28:49 +00:00
--ok-label "Cancel" \
--extra-button "Internal" \
2022-07-22 17:08:10 +00:00
--extra-button "SD Card" \
--text= "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 roms folder to be located?" )
echo " Choice is $choice "
case $choice in
2022-09-24 18:28:49 +00:00
"" ) # Cancel or X button quits
2022-07-22 17:08:10 +00:00
echo "Now quitting"
kill $$
2022-09-24 18:28:49 +00:00
; ;
"Internal" ) # Internal
echo "Internal selected"
roms_folder = " $rdhome /roms "
; ;
2022-07-22 17:08:10 +00:00
"SD Card" )
echo "SD Card selected"
if [ ! -d " $sdcard " ] # SD Card path is not existing
then
echo "Error: SD card not found"
zenity --question --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" --cancel-label= "Cancel" \
--ok-label "Browse" \
--text= "SD Card was not find in the default location.\nPlease choose the SD Card root.\nA retrodeck/roms folder will be created starting from the directory that you selected."
2022-09-16 07:11:41 +00:00
browse # Calling the browse function
2022-07-22 17:08:10 +00:00
else
2022-09-19 07:04:44 +00:00
roms_folder = " $sdcard /retrodeck/roms " # sdcard variable is correct as its given by browse function
2022-07-22 17:08:10 +00:00
echo " ROMs folder = $roms_folder "
fi
2022-09-24 18:28:49 +00:00
; ;
2022-07-22 17:08:10 +00:00
2022-09-24 18:28:49 +00:00
#"Advanced" ) # Browse + not found fallback
# echo "Advanced"
# advanced
#;;
2022-09-21 14:22:00 +00:00
2022-07-22 17:08:10 +00:00
esac
2022-05-19 14:30:43 +00:00
mkdir -pv $roms_folder
# TODO: after the next update of ES-DE this will not be needed
2022-06-08 12:49:53 +00:00
#zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text="EmulationStation will now initialize the system.\nPlease DON'T EDIT THE ROMS LOCATION, just select:\n\nCREATE DIRECTORIES\nYES\nOK\nQUIT\n\nRetroDECK will manage the rest."
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap --window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text= "RetroDECK will now install the needed files.\nPlease wait up to one minute,\nanother message will notify when the process will be finished.\n\nPress OK to continue."
2022-05-19 14:30:43 +00:00
# Recreating the folder
2022-06-08 09:54:58 +00:00
rm -rfv /var/config/emulationstation/
rm -rfv /var/config/retrodeck/tools/
2022-05-19 14:30:43 +00:00
mkdir -pv /var/config/emulationstation/
2022-10-13 12:21:30 +00:00
2022-05-19 14:30:43 +00:00
# Initializing ES-DE
2022-06-08 12:49:53 +00:00
# TODO: after the next update of ES-DE this will not be needed - let's test it
emulationstation --home /var/config/emulationstation --create-system-dirs
2022-05-19 14:30:43 +00:00
2022-06-08 09:54:58 +00:00
mkdir -pv /var/config/retrodeck/tools/
2022-06-08 12:49:53 +00:00
#zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --text="RetroDECK will now install the needed files.\nPlease wait up to one minute,\nanother message will notify when the process will be finished.\n\nPress OK to continue."
2022-05-19 14:30:43 +00:00
# Initializing ROMs folder - Original in retrodeck home (or SD Card)
dir_prep $roms_folder "/var/config/emulationstation/ROMs"
mkdir -pv $rdhome /saves
mkdir -pv $rdhome /states
mkdir -pv $rdhome /screenshots
2022-06-22 20:55:01 +00:00
mkdir -pv $rdhome /bios/pico8
2022-05-21 13:25:06 +00:00
mkdir -pv $rdhome /.logs
2022-05-19 14:30:43 +00:00
# XMLSTARLET HERE
2022-06-22 20:16:30 +00:00
cp -fv /app/retrodeck/es_settings.xml /var/config/emulationstation/.emulationstation/es_settings.xml
2022-05-19 14:30:43 +00:00
# ES-DE preparing themes and scraped folders
2022-07-10 19:48:19 +00:00
dir_prep " $rdhome /downloaded_media " "/var/config/emulationstation/.emulationstation/downloaded_media"
dir_prep " $rdhome /themes " "/var/config/emulationstation/.emulationstation/themes"
2022-05-19 14:30:43 +00:00
2022-05-20 06:37:43 +00:00
# PICO-8
2022-06-22 20:55:01 +00:00
dir_prep " $roms_folder /pico8 " " $rdhome /bios/pico8/bbs/carts " #this is the folder where pico-8 is saving the carts
2022-05-20 06:37:43 +00:00
2022-05-19 14:30:43 +00:00
ra_init
standalones_init
tools_init
create_lock
2022-07-28 14:35:13 +00:00
zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK" \
2022-08-04 19:40:04 +00:00
--text= " Installation completed.\nPlease put your roms in:\n\n $roms_folder \n\nand your bioses in\n\n $rdhome /bios\n\nThen start the program again.\nIf you wish to change the roms location, you may use the tool located the tools section of RetroDECK.\n\nIMPORTANT NOTES:\n- RetroDECK must be manually added and launched from your Steam Library in order to work correctly.\n- It's recommended to use the 'RetroDECK Offical Controller Config' from Steam (under community layouts).\n- It's suggested to use BoilR to automatically add the SteamGridDB images to Steam (this will be automated soon).\nhttps://github.com/PhilipK/BoilR "
2022-05-19 14:30:43 +00:00
# TODO: Replace the stuff above with BoilR code when ready
}
# Arguments section
2022-05-18 14:10:32 +00:00
for i in " $@ " ; do
case $i in
-h*| --help*)
2022-09-06 12:46:59 +00:00
echo "RetroDECK v" " $version "
2022-05-18 14:10:32 +00:00
echo "
Usage:
flatpak run [ FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ ARGUMENTS]
Arguments:
2022-05-19 14:30:43 +00:00
-h, --help Print this help
-v, --version Print RetroDECK version
2022-08-04 19:40:04 +00:00
--info-msg Print paths and config informations
2022-05-19 14:30:43 +00:00
--reset Starts the initial RetroDECK installer ( backup your data first!)
--reset-ra Resets RetroArch' s config to the default values
--reset-sa Reset standalone emulator configs to the default values
--reset-tools Recreate the tools section
2022-05-18 14:10:32 +00:00
For flatpak run specific options please run: flatpak run -h
https://retrodeck.net
"
exit
; ;
--version*| -v*)
2022-09-06 12:46:59 +00:00
#conf_init
2022-08-04 19:40:04 +00:00
echo " RetroDECK v $version "
exit
; ;
--info-msg*)
2022-09-06 12:46:59 +00:00
#conf_init
2022-08-04 19:40:04 +00:00
echo " RetroDECK v $version "
echo " RetroDECK config file is in: $rd_conf "
echo "Contents:"
cat $rd_conf
2022-05-18 14:10:32 +00:00
exit
; ;
2022-05-19 14:30:43 +00:00
--reset-ra*)
ra_init
shift # past argument with no value
; ;
--reset-sa*)
standalones_init
shift # past argument with no value
; ;
--reset-tools*)
tools_init
2022-05-18 14:10:32 +00:00
shift # past argument with no value
; ;
2022-05-20 06:37:43 +00:00
--reset*)
rm -f " $lockfile "
shift # past argument with no value
; ;
2022-05-18 14:10:32 +00:00
-*| --*)
echo " Unknown option $i "
exit 1
; ;
*)
; ;
esac
done
2022-05-19 14:30:43 +00:00
# UPDATE TRIGGERED
2022-09-06 12:46:59 +00:00
# if lockfile exists
if [ -f " $lockfile " ]
2022-03-28 13:01:47 +00:00
then
2022-03-31 06:03:00 +00:00
2022-09-06 12:46:59 +00:00
#conf_init # Initializing/reading the config file (sourced from global.sh)
# ...but the version doesn't match with the config file
2022-10-13 12:21:30 +00:00
if [ " $hard_version " != " $version " ] ;
2022-09-06 12:46:59 +00:00
then
2022-09-10 15:47:53 +00:00
echo " Config file's version is $version but the actual version is $hard_version "
2022-09-06 12:46:59 +00:00
post_update # Executing post update script
conf_write # Writing variables in the config file (sourced from global.sh)
start_retrodeck
exit 0
fi
# Else, LOCKFILE IS NOT EXISTING (WAS REMOVED)
2022-05-19 14:30:43 +00:00
# if the lock file doesn't exist at all means that it's a fresh install or a triggered reset
2022-10-13 12:21:30 +00:00
else
2022-05-19 14:30:43 +00:00
echo "Lockfile not found"
2022-09-06 12:46:59 +00:00
#conf_init # Initializing/reading the config file (sourced from global.sh)
2022-07-22 17:23:38 +00:00
finit # Executing First/Force init
conf_write # Writing variables in the config file (sourced from global.sh)
2022-05-19 14:30:43 +00:00
exit 0
2022-04-02 09:21:05 +00:00
fi
2022-05-19 14:30:43 +00:00
# Normal Startup
start_retrodeck