2022-03-27 13:30:22 +00:00
#!/bin/bash
2022-10-24 19:49:47 +00:00
source /app/libexec/global.sh
2022-11-18 20:10:17 +00:00
source /app/libexec/post_update.sh
2022-07-10 19:48:19 +00:00
2022-05-19 14:30:43 +00:00
# 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:
2023-03-07 16:28:57 +00:00
-h, --help Print this help
-v, --version Print RetroDECK version
--info-msg Print paths and config informations
2023-03-08 15:33:38 +00:00
--configurator Starts the RetroDECK Configurator
2023-03-07 16:28:57 +00:00
--compress <file> Compresses target file to .chd format. Supports .cue, .iso and .gdi formats
--reset-emulator <emulator> Reset one or more emulator configs to the default values
--reset-tools Reset the RetroDECK Tools section
--reset-retrodeck Starts the initial RetroDECK installer ( backup your data first!)
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-08-04 19:40:04 +00:00
echo " RetroDECK v $version "
exit
; ;
--info-msg*)
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
; ;
2023-03-06 17:50:25 +00:00
--compress*)
2023-03-07 17:15:24 +00:00
read -p "RetroDECK will now attempt to compress your selected game. The original game will still exist and will need to be removed manually after the process completes. Press any key to continue..."
2023-03-06 17:50:25 +00:00
if [ [ ! -z $2 ] ] ; then
if [ [ -f $2 ] ] ; then
2023-03-08 15:33:38 +00:00
current_run_log_file = "chd_compression_" $( date +"%Y_%m_%d_%I_%M_%p" ) .log""
if [ [ $( validate_for_chd $2 ) = = "true" ] ] ; then
filename_no_path = $( basename $2 )
filename_no_extension = ${ filename_no_path %.* }
compress_to_chd $( dirname $( realpath $2 ) ) /$( basename $2 ) $( dirname $( realpath $2 ) ) /$filename_no_extension
else
printf "An error occured during the compression process. Please see the following log entries for details:\n\n"
cat $logs_folder /$current_run_log_file
fi
2023-03-06 17:50:25 +00:00
else
echo "File not found, please specify the full path to the file to be compressed."
fi
else
2023-03-08 15:33:38 +00:00
echo "Please use this command format \"--compress <cue/gdi/iso file to compress>\""
2023-03-12 18:21:30 +00:00
fi
2023-03-06 20:18:22 +00:00
exit
2023-03-06 17:50:25 +00:00
; ;
2023-03-08 15:33:38 +00:00
--configurator*)
2023-03-06 17:50:25 +00:00
sh /var/config/retrodeck/tools/configurator.sh
2023-03-06 20:18:22 +00:00
exit
2023-03-06 17:50:25 +00:00
; ;
2023-03-07 16:28:57 +00:00
--reset-emulator*)
echo "You are about to reset one or more RetroDECK emulators."
echo "Available options are: retroarch citra dolphin duckstation melonds pcsx2 ppsspp primehack rpcs3 xemu yuzu all-emulators"
read -p "Please enter the emulator you would like to reset: " emulator
if [ [ " $emulator " = ~ ^( retroarch| citra| dolphin| duckstation| melonds| pcsx2| ppsspp| primehack| rpcs3| xemu| yuzu| all-emulators) $ ] ] ; then
read -p " You are about to reset $emulator to default settings. Press 'y' to continue, 'n' to stop: " response
if [ [ $response = = [ yY] ] ] ; then
cli_emulator_reset $emulator
read -p "The process has been completed, press any key to start RetroDECK."
shift # Continue launch after previous command is finished
else
read -p "The process has been cancelled, press any key to exit."
exit
fi
else
echo " $emulator is not a valid selection, exiting... "
exit
fi
2022-05-19 14:30:43 +00:00
; ;
--reset-tools*)
2023-03-07 16:28:57 +00:00
echo "You are about to reset the RetroDECK tools."
read -p "Press 'y' to continue, 'n' to stop: " response
if [ [ $response = = [ yY] ] ] ; then
tools_init
read -p "The process has been completed, press any key to start RetroDECK."
shift # Continue launch after previous command is finished
else
read -p "The process has been cancelled, press any key to exit."
exit
fi
2022-05-18 14:10:32 +00:00
; ;
2023-03-07 16:28:57 +00:00
--reset-retrodeck*)
echo "You are about to reset RetroDECK completely."
read -p "Press 'y' to continue, 'n' to stop: " response
if [ [ $response = = [ yY] ] ] ; then
rm -f " $lockfile "
2023-03-07 17:24:59 +00:00
read -p "The process has been completed, press any key to start the initial RetroDECK setup process."
2023-03-07 16:28:57 +00:00
shift # Continue launch after previous command is finished
else
read -p "The process has been cancelled, press any key to exit."
exit
fi
2022-05-20 06:37:43 +00:00
; ;
2022-05-18 14:10:32 +00:00
-*| --*)
echo " Unknown option $i "
exit 1
; ;
*)
2023-03-07 17:24:59 +00:00
echo "Please specify a valid option. Use -h for more information."
2022-05-18 14:10:32 +00:00
; ;
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-09-06 12:46:59 +00:00
# ...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-12-22 15:34:50 +00:00
echo " Config file's version is $version but the actual version is $hard_version "
post_update # Executing post update script
2022-09-06 12:46:59 +00:00
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"
2023-03-12 18:21:30 +00:00
if [ [ check_network_connectivity = = "true" ] ] ; then
finit # Executing First/Force init
else
configurator_generic_dialog "You do not appear to be connected to a network with internet access.\n\nThe initial RetroDECK setup requires some files from the internet to function properly.\n\nPlease retry this process once a network connection is available."
exit 1
fi
2022-04-02 09:21:05 +00:00
fi
2022-05-19 14:30:43 +00:00
2023-03-13 14:09:01 +00:00
# Check if running in Desktop mode and warn if true, unless desktop_mode_warning=false in retrodeck.cfg
2023-03-07 17:00:32 +00:00
2023-03-13 14:09:01 +00:00
desktop_mode_warning
2023-03-07 17:00:32 +00:00
2022-12-22 15:34:50 +00:00
# Normal Startup
2022-10-03 18:48:07 +00:00
start_retrodeck