forked from RetroDECK/RetroDECK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
retrodeck.sh
201 lines (186 loc) · 9.78 KB
/
retrodeck.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
source /app/libexec/global.sh
# Arguments section
for i in "$@"; do
case $i in
-h*|--help*)
echo "RetroDECK v""$version"
echo "
Usage:
flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
Arguments:
-h, --help Print this help
-v, --version Print RetroDECK version
--info-msg Print paths and config informations
--configurator Starts the RetroDECK Configurator
--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\".
--reset-component <component> Reset one or more component or emulator configs to the default values
--reset-retrodeck Starts the initial RetroDECK installer (backup your data first!)
For flatpak run specific options please run: flatpak run -h
https://retrodeck.net
"
exit
;;
--version*|-v*)
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
;;
--compress-one*)
cli_compress_single_game "$2"
exit
;;
--compress-all*)
cli_compress_all_games "$2"
;;
--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*)
echo "You are about to reset one or more RetroDECK components or emulators."
echo "Available options are: es-de, retroarch, cemu, dolphin, duckstation, gzdoom, melonds, pcsx3, pico8, ppsspp, primehack, rpcs3, ryujinx, xemu, vita3k, mame, boilr, all"
read -p "Please enter the component you would like to reset: " component
if [[ "$component" =~ ^(es-de|retroarch|cemu|dolphin|duckstation|gzdoom|mame|melonds|pcsx2|ppsspp|primehack|ryujinx|rpcs3|xemu|all)$ ]]; then
read -p "You are about to reset $component to default settings. Enter 'y' to continue, 'n' to stop: " response
if [[ $response == [yY] ]]; then
prepare_component "reset" "$component" "cli"
read -p "The process has been completed, press Enter key to start RetroDECK."
shift # Continue launch after previous command is finished
else
read -p "The process has been cancelled, press Enter key to exit."
exit
fi
else
echo "$component is not a valid selection, exiting..."
exit
fi
;;
--reset-retrodeck*)
echo "You are about to reset RetroDECK completely!"
read -p "Enter 'y' to continue, 'n' to stop: " response
if [[ $response == [yY] ]]; then
rm -f "$lockfile"
rm -f "$rd_conf"
read -p "The process has been completed, press Enter key to exit. Please run RetroDECK again to start the initial setup process."
exit 1
else
read -p "The process has been cancelled, press Enter key to exit."
exit
fi
;;
-*|--*)
echo "Unknown option $i"
exit 1
;;
*)
validate_input "$i"
if [[ ! $input_validated == "true" ]]; then
echo "Please specify a valid option. Use -h for more information."
fi
;;
esac
done
log d "Update triggered"
# if lockfile exists
if [ -f "$lockfile" ]; then
if [ "$hard_version" != "$version" ]; then
log d "Lockfile found but the version doesn't match with the config file"
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
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" "RetroDECK-cooker" retrodeck "options"
set_setting_value $rd_conf "update_check" "true" retrodeck "options"
set_setting_value $rd_conf "developer_options" "true" retrodeck "options"
cooker_base_version=$(echo $hard_version | cut -d'-' -f2)
choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Upgrade" --extra-button="Don't Upgrade" --extra-button="Full Wipe and Fresh Install" \
--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.")
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.
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
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
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
fi
else
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.
post_update
fi
else # If newly-installed version is a normal build.
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.
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"
set_setting_value $rd_conf "developer_options" "false" retrodeck "options"
fi
post_update # Executing post update script
fi
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
else
log w "Lockfile not found"
finit # Executing First/Force init
fi
if [[ $multi_user_mode == "true" ]]; then
multi_user_determine_current_user
fi
# 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
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
# THIS IS A ONE-OFF FORCED REFRESH OF RETRODECK CONTROLLER PROFILES IN A 0.7.6b VERSION REFRESH - REMOVE BEFORE NEXT VERSION RELEASE
if [[ -f "$HOME/.steam/steam/controller_base/templates/RetroDECK_controller_config.vdf" ]]; then # If RetroDECK controller profile has been previously installed
install_retrodeck_controller_profile
fi
# REMOVE BEFORE NEXT VERSION RELEASE
# Normal Startup
if [[ $steam_sync == "true" ]]; then
python3 /app/libexec/steam-sync/steam-sync.py &
fi
start_retrodeck
if [[ $steam_sync == "true" ]]; then
touch /tmp/retrodeck_steam_sync_exit
fi