RetroDECK/retrodeck.sh

260 lines
12 KiB
Bash
Raw Normal View History

2022-03-27 13:30:22 +00:00
#!/bin/bash
source /app/libexec/global.sh
show_cli_help() {
echo -e "
2025-02-07 00:55:13 +00:00
Usage:
flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
Arguments:
-h, --help \t Print this help
-v, --version \t Print RetroDECK version
--info-msg \t Print paths and config informations
2025-02-07 00:55:13 +00:00
--debug \t Enable debug logging for this run of RetroDECK
--configurator \t Starts the RetroDECK Configurator
--compress-one <file> \t Compresses target file to a compatible format
2024-09-12 05:49:19 +00:00
--compress-all <format> \t Compresses all supported games into a compatible format.\n\t\t\t\t\t\t Available formats are \"chd\", \"zip\", \"rvz\" and \"all\"
--reset <component> \t Reset RetroDECK or one or more component/emulator configurations to default values. WARNING: no confirmation prompt
--factory-reset \t Factory Reset, triggers the initial setup WARNING: no confirmation prompt
--test-upgrade <version> \t Test upgrading RetroDECK to a specific version, developer use only
2025-02-07 00:55:13 +00:00
--set <preset> <system/all> [value] \t Configure or toggle a preset. Examples: --set borders, --set borders all true,\n\t\t\t\t\t\t --set borders gba false. Use --set help for more information
--open <component/emulator> \t Open a specific component or emulator\n\t\t\t\t\t\t --open --list for a list of available components
Game Launch:
[<options>] <game_path> \t Start a game using the default emulator or\n\t\t\t\t\t\t the one defined in ES-DE for game or system
\t Options:
2024-09-12 05:49:19 +00:00
\t \t-e (emulator)\t Run the game with the defined emulator (optional)
\t \t-s (system)\t Force the game running with the defined system, for example running a gb game on gba (optional)
\t \t-m (manual)\t Manual mode: show the list of available emulator to choose from (optional)
For flatpak run specific options please run: flatpak run -h
2025-02-07 00:55:13 +00:00
The RetroDECK Team
https://retrodeck.net
"
}
# Arguments section
for i in "$@"; do
case $i in
-h*|--help*)
2025-02-07 00:55:13 +00:00
if [[ "$version" == *"cooker"* ]]; then
echo "RetroDECK $version"
else
echo "RetroDECK v$version"
fi
show_cli_help
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
exit
;;
2024-10-18 13:40:48 +00:00
--debug*)
logging_level="debug"
shift
;;
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-29 19:51:27 +00:00
--compress-all*)
cli_compress_all_games "$2"
;;
2023-03-08 15:33:38 +00:00
--configurator*)
sh /app/tools/configurator.sh
#sh /app/bin/godot-configurator.sh
exit 0
;;
# --legacy-configurator*)
# sh /app/tools/configurator.sh
# if [[ $(configurator_generic_question_dialog "RetroDECK Configurator" "Would you like to launch RetroDECK after closing the Configurator?") == "false" ]]; then
# exit
# else
# shift
# fi
# ;;
--reset*)
component="${@:2}"
if [ -z "$component" ]; then
echo "You are about to reset one or more RetroDECK components or emulators."
echo -e "Available options are:\nall, $(prepare_component --list | tr ' ' ',' | sed 's/,/, /g')"
read -p "Please enter the component you would like to reset: " component
component=$(echo "$component" | tr '[:upper:]' '[:lower:]')
fi
log d "Resetting component: $component"
prepare_component "reset" "$component"
exit
;;
--factory-reset*)
prepare_component --factory-reset
;;
--test-upgrade*)
2025-02-05 01:03:26 +00:00
if [[ "$2" =~ ^.+ ]]; then
echo "You are about to test upgrading RetroDECK from version $2 to $hard_version"
read -p "Enter 'y' to continue, 'n' to start RetroDECK normally: " response
if [[ $response == [yY] ]]; then
version="$2"
2025-02-05 01:03:26 +00:00
logging_level="debug" # Temporarily enable debug
shift 2
else
shift
fi
2025-02-05 01:03:26 +00:00
else
echo "Error: Invalid format. Usage: --test-upgrade <version>"
exit 1
fi
;;
--set*)
preset="$2"
if [ "$preset" == "cheevos" ]; then
echo "Error: The 'cheevos' preset is not yet supported via CLI. Please use the RetroDECK Configurator."
exit 1
fi
value="$3"
if [ -z "$preset" ]; then
echo "Error: No preset specified. Usage: --set <preset> [value], --set help for more help"
exit 1
fi
if [ "$preset" == "help" ]; then
echo "Used to toggle or set a preset. Available presets are:"
fetch_all_presets
echo "Usage: --set <preset> [value]"
echo "Examples:"
echo "Force borders to be true for gba:"
echo " make_preset_changes borders gba true"
echo "Force borders to be true for all supported systems:"
echo " make_preset_changes borders all true"
echo "Toggle gba in preset borders, this will disable the enabled and vice versa:"
echo " make_preset_changes borders gba true"
echo "Toggle all in preset borders:"
echo " make_preset_changes borders all"
exit 0
fi
make_preset_changes "$preset" "$value"
exit 0
;;
--open*)
open_component "${@:2}"
exit 0
;;
*)
# Assume unknown arguments are game start arguments
if [ -f "$i" ]; then
log i "Attempting to start the game: $i"
run_game "$@"
exit
elif [[ "$i" == "-e" || "$i" == "-s" || "$i" == "-m" ]]; then
log i "Game start option detected: $i"
run_game "$@"
exit
else
log i "Command or File '$i' not found. Ignoring argument and continuing..."
break # Continue with the main program
2023-03-20 13:23:04 +00:00
fi
;;
-*|--*)
log i "Unknown option $i"
show_cli_help
exit 1
;;
esac
done
2022-09-06 12:46:59 +00:00
# if lockfile exists
if [ -f "$lockfile" ]; then
if [ "$hard_version" != "$version" ]; then
log d "Update triggered"
log d "Lockfile found but the version doesn't match with the config file"
2024-01-04 16:34:02 +00:00
log i "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
log d "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!"
set_setting_value $rd_conf "update_repo" "$cooker_repository_name" retrodeck "options"
2023-05-19 14:03:02 +00:00
set_setting_value $rd_conf "update_check" "true" retrodeck "options"
set_setting_value $rd_conf "developer_options" "true" retrodeck "options"
cooker_base_version=$(echo $version | cut -d'-' -f2)
choice=$(rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Upgrade" --extra-button="Don't Upgrade" --extra-button="Full Wipe and Fresh Install" \
2023-04-03 15:07:42 +00:00
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Cooker Upgrade" \
--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 folders and data (including ROMs and saves) 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.
2024-01-04 16:34:02 +00:00
log i "Skipping upgrade process for cooker build, updating stored version in retrodeck.cfg"
2023-04-03 15:07:42 +00:00
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
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" "Are you super sure?\n\nThere is no going back from this process, everything is gonzo.\nDust in the wind.\n\nYesterdays omelette.") == "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!"
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "(Are you actually being serious here? Because we are...\n\nNo backsies.)") == "true" ]]; then
2024-01-04 16:34:02 +00:00
log w "Removing RetroDECK data and starting fresh"
rm -rf /var
rm -rf "$HOME/retrodeck"
rm -rf "$rdhome"
source /app/libexec/global.sh
finit
fi
fi
fi
fi
2023-04-03 15:07:42 +00:00
fi
else
log i "Performing normal upgrade process for version $cooker_base_version"
2023-04-03 15:07:42 +00:00
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
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"
set_setting_value $rd_conf "update_ignore" "" retrodeck "options"
2023-05-19 14:03:02 +00:00
set_setting_value $rd_conf "developer_options" "false" 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)
# 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
2024-01-04 16:34:02 +00:00
log w "Lockfile not found"
finit # Executing First/Force init
2022-04-02 09:21:05 +00:00
fi
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
if [[ $(check_is_steam_deck) == "true" ]]; then # Only warn about Desktop Mode on Steam Deck, ignore for other platforms
desktop_mode_warning
fi
2023-05-08 20:54:35 +00:00
low_space_warning
# Check if there is a new version of RetroDECK available, if update_check=true in retrodeck.cfg and there is network connectivity available.
log i "Check if there is a new version of RetroDECK available"
if [[ $update_check == "true" ]]; then
if [[ $(check_network_connectivity) == "true" ]]; then
log d "Running function check_for_version_update"
check_for_version_update
fi
log i "You're running the latest version"
fi
# Normal Startup
2023-04-14 12:49:21 +00:00
start_retrodeck
feat/steam-rom-manager (#860) * SRM: adding Steam ROM Manager * SRM: adding electron base * Fixed SRM Fixed launching script of SRM * Updated for srm * Standard config for srm * Update with srm in place of boilr * Update with srm in place of boilr * Added steam-sync option * PREPARE_COMPONENTS: removing spaces from steam rom manager * SRM: adding it ot reset cli, boilr cleanup * SRM: boilr cleanup [skip ci] * Update and fixed script * Modified steam sync works * Update configurator.sh * STEAM_SYNC: fixing gameslist location * SRM: fixed path, whoops * Added file for resetting the configuration * Modified with external reset function * Modified with external reset function * Added msgbox during fav sync * STEAM_SYNC: fixed some texts * Modified if for remove everything if no favorite games * Fixed removing the games when no favs * STEAM_ROM_MANAGER: added to features.json * STEAM_ROM_MANAGER: casing names descriptions * Fixed some error * Moved away the creation of .sync folder * Uploaded standard exception * Added reset userExceptions * Revert missing entrypoint * STEAM_SYNC_SH: checkpoint, addToSteam is working * STEAM_SYNC_SH: fixed bad launcher filename generation * STEAM_SYNC_SH: fixed game names, unified in a single function, code cleanup * STEAM_SYNC_SH: removed deprecated commands [skip ci] * STEAM_SYNC_SH: fixed launcher with correct command [skip ci] * STEAM_SYNC_SH: added prepare_component [skip ci] * STEAM_SYNC_SH: code cleanup [skip ci] * STEAM_SYNC_SH: moved it on retrodeck quit instead of retrodeck start [skip ci] * STEAM_SYNC_SH: updated userConfigurations.json [skip ci] * STEAM_SYNC_SH: code cleanup * Triggering build * STEAM_SYNC: globalized steamsync_folder variable * STEAM_SYNC: standardized script name * STEAM_SYNC: fixing array * STEAM_SYNC: fixing array -part2 * POST_UPDATE: enhanced for steam_rom_manager * STEAM_SYNC: this variable is not correct here * STEAM_SYNC: fixing configuration * STEAM_SYNC: adding more sanitized games cases * STEAM_SYNC: fix framwork was shutting down before steam_sync * MANIFEST: fixed SRM wrapper to accept args * STEAM_SYNC: fixing SRM preparation * STEAM_SYNC: using run_game to build the launchers * STEAM_SYNC: added system to run_game be sure * STEAM_SYNC_SH: removed unused config file * FEATURES: indentation fix * PREPARE_COMPONENT: comments * STEAM_SYNC_SH: general optimization and bugfixes * STEAM_SYNC_SH: migrated launcher to the new run_game * FEATURES: rebased from cooker * FEATURES: fmt [skip ci] * STEAM_SYNC: using new start command + cleanup * STEAM_SYNC: migrated launches to .desktop files * STEAM_SYNC: reverted .desktop files * STEAM_SYNC: romed -s from launcher * STEAM_SYNC: comments for calling quit function [skip ci] * Create file only if does not exists + fixed syntax * Added full shortcut clean * Fixed check if file exists * Added remove no fav game * Fixed comment error and +x chmod --------- Co-authored-by: Lx32 <loxenfabula@gmail.com>
2024-10-28 01:01:44 +00:00
# After everything is closed we run the quit function
quit_retrodeck