2022-03-27 13:30:22 +00:00
#!/bin/bash
2022-10-24 19:49:47 +00:00
source /app/libexec/global.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-29 19:51:27 +00:00
--compress-one <file> Compresses target file to a compatible format
--compress-all <format> Compresses all supported games into compatible format. Available formats are \" chd\" , \" zip\" , \" rvz\" and \" all\" .
2023-03-07 16:28:57 +00:00
--reset-emulator <emulator> Reset one or more emulator configs to the default values
--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-29 19:51:27 +00:00
--compress-one*)
cli_compress_single_game " $2 "
2023-03-06 20:18:22 +00:00
exit
2023-03-06 17:50:25 +00:00
; ;
2023-03-29 19:51:27 +00:00
--compress-all*)
cli_compress_all_games " $2 "
; ;
2023-03-08 15:33:38 +00:00
--configurator*)
2023-05-12 18:28:51 +00:00
launched_from_cli = "true"
2023-03-22 12:32:21 +00:00
sh /app/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."
2023-04-11 13:11:12 +00:00
echo "Available options are: retroarch cemu citra dolphin duckstation melonds pcsx2 ppsspp primehack rpcs3 xemu yuzu all-emulators"
2023-03-07 16:28:57 +00:00
read -p "Please enter the emulator you would like to reset: " emulator
2023-04-11 13:11:12 +00:00
if [ [ " $emulator " = ~ ^( retroarch| cemu| citra| dolphin| duckstation| melonds| pcsx2| ppsspp| primehack| rpcs3| xemu| yuzu| all-emulators) $ ] ] ; then
2023-03-20 20:46:09 +00:00
read -p " You are about to reset $emulator to default settings. Enter 'y' to continue, 'n' to stop: " response
2023-03-07 16:28:57 +00:00
if [ [ $response = = [ yY] ] ] ; then
2023-04-17 20:03:29 +00:00
prepare_emulator "reset" " $emulator " "cli"
2023-03-15 21:19:04 +00:00
read -p "The process has been completed, press Enter key to start RetroDECK."
2023-03-07 16:28:57 +00:00
shift # Continue launch after previous command is finished
else
2023-03-15 21:19:04 +00:00
read -p "The process has been cancelled, press Enter key to exit."
2023-03-07 16:28:57 +00:00
exit
fi
else
echo " $emulator is not a valid selection, exiting... "
exit
fi
2022-05-19 14:30:43 +00:00
; ;
2023-03-07 16:28:57 +00:00
--reset-retrodeck*)
2023-03-15 21:19:04 +00:00
echo "You are about to reset RetroDECK completely!"
2023-03-20 20:46:09 +00:00
read -p "Enter 'y' to continue, 'n' to stop: " response
2023-03-07 16:28:57 +00:00
if [ [ $response = = [ yY] ] ] ; then
rm -f " $lockfile "
2023-03-20 20:46:09 +00:00
rm -f " $rd_conf "
2023-03-15 21:19:04 +00:00
read -p "The process has been completed, press Enter 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
2023-03-15 21:19:04 +00:00
read -p "The process has been cancelled, press Enter key to exit."
2023-03-07 16:28:57 +00:00
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-20 13:23:04 +00:00
validate_input " $i "
if [ [ ! $input_validated = = "true" ] ] ; then
echo "Please specify a valid option. Use -h for more information."
fi
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
2023-05-10 13:57:28 +00:00
if [ -f " $lockfile " ] ; then
2022-09-06 12:46:59 +00:00
# ...but the version doesn't match with the config file
2023-05-10 13:57:28 +00:00
if [ " $hard_version " != " $version " ] ; then
2022-12-22 15:34:50 +00:00
echo " Config file's version is $version but the actual version is $hard_version "
2023-04-03 15:07:42 +00:00
if grep -qF "cooker" <<< $hard_version ; then # If newly-installed version is a "cooker" build
2023-04-20 14:51:17 +00:00
cooker_base_version = $( echo $hard_version | cut -d'-' -f2)
2023-04-03 15:07:42 +00:00
choice = $( zenity --icon-name= net.retrodeck.retrodeck --info --no-wrap --ok-label= "Upgrade" --extra-button= "Don't Upgrade" --extra-button= "Fresh Install" \
--window-icon= "/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Cooker Upgrade" \
2023-04-20 14:51:17 +00:00
--text= "You appear to be upgrading to a \"cooker\" build of RetroDECK.\n\nWould you like to perform the standard post-update process, skip the post-update process or remove ALL existing RetroDECK data to start from a fresh install?\n\nPerforming the normal post-update process multiple times may lead to unexpected results." )
2023-04-03 15:07:42 +00:00
rc = $? # Capture return code, as "Yes" button has no text value
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.
echo "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
elif [ [ $choice = = "Fresh Install" ] ] ; then # Remove all RetroDECK data and start a fresh install
echo "Removing RetroDECK data and starting fresh"
rm -rf /var
rm -rf " $HOME /retrodeck "
2023-04-20 14:51:17 +00:00
source /app/libexec/global.sh
2023-04-03 15:07:42 +00:00
finit
fi
else
echo "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.
post_update
fi
else # If newly-installed version is a normal build.
2023-04-19 21:08:00 +00:00
if grep -qF "cooker" <<< $version ; then # If previously installed version was a cooker build
2023-05-10 13:57:28 +00:00
cooker_base_version = $( echo $version | cut -d'-' -f2)
version = $cooker_base_version # Temporarily assign cooker base version to $version so update script can read it properly.
2023-04-18 15:26:35 +00:00
set_setting_value $rd_conf "update_repo" "RetroDECK" retrodeck "options"
set_setting_value $rd_conf "update_check" "false" retrodeck "options"
2023-04-20 19:56:41 +00:00
set_setting_value $rd_conf "update_ignore" "" retrodeck "options"
2023-04-18 15:26:35 +00:00
fi
2023-04-03 15:07:42 +00:00
post_update # Executing post update script
2023-04-14 12:49:21 +00:00
fi
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-05-17 13:53:59 +00:00
finit # Executing First/Force init
2022-04-02 09:21:05 +00:00
fi
2022-05-19 14:30:43 +00:00
2023-03-30 14:04:11 +00:00
if [ [ $multi_user_mode = = "true" ] ] ; then
multi_user_determine_current_user
fi
2023-05-08 20:54:35 +00:00
# Run optional startup checks
2023-03-07 17:00:32 +00:00
2023-03-13 14:09:01 +00:00
desktop_mode_warning
2023-05-08 20:54:35 +00:00
low_space_warning
2023-03-07 17:00:32 +00:00
2023-03-27 19:52:58 +00:00
# Check if there is a new version of RetroDECK available, if update_check=true in retrodeck.cfg and there is network connectivity available.
2023-04-14 13:10:52 +00:00
if [ [ $( check_network_connectivity) = = "true" ] ] && [ [ $update_check = = "true" ] ] ; then
2023-03-27 19:52:58 +00:00
check_for_version_update
fi
2022-12-22 15:34:50 +00:00
# Normal Startup
2023-04-14 12:49:21 +00:00
start_retrodeck