Add a failsafe for server type change

This commit is contained in:
Jiří Štefka 2023-03-02 20:35:23 +01:00
parent 3563330d6b
commit 353b49a76d
2 changed files with 37 additions and 2 deletions

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
EXTRA_SCRIPTS_VERSION="v2.0.1" EXTRA_SCRIPTS_VERSION="v2.1.1"

@ -8,7 +8,7 @@ set -e
# and acknowledge the original script and author. # # and acknowledge the original script and author. #
############################################################################################################# #############################################################################################################
CURRENT_SCRIPT_VERSION="v2.0.1" CURRENT_SCRIPT_VERSION="v2.1.1"
# -------------------------------------------------- # --------------------------------------------------
# You shouldn't need to change anything in this file # You shouldn't need to change anything in this file
@ -132,6 +132,36 @@ function ask_version_differs {
fi fi
} }
# Ask if the new server version differs from the old one
function ask_server_type_differs {
echo
echo
echo "The current server type differs from the one you selected."
echo "The server version is $existing_server_type and the selected type is $server_type."
echo "Do you want to change the server type?"
echo "This can cause many issues if you don't know what you are doing."
echo
echo "I am not responsible for any data loss caused by changing the server type."
echo
echo "You have 15 seconds to respond, or the script will exit"
read -t 15 -p "Do you want to change the server type? [y/N] " type_differs
if [ "$type_differs" != "y" ] && [ "$type_differs" != "Y" ]; then
echo "Server type not changed."
echo "To start the server again with the server type, change the server type in the config to $existing_server_type."
exit 4
fi
if [ "$type_differs" == "y" ] || [ "$type_differs" == "Y" ]; then
read -t 15 -p "Are you sure you want to change the server type? [y/N] " type_differs
if [ "$type_differs" != "y" ] && [ "$type_differs" != "Y" ]; then
echo "Server type not changed."
echo "To start the server again with the server type, change the server type in the config to $existing_server_type."
exit 4
fi
fi
}
# Ask if the new server version differs from the old one # Ask if the new server version differs from the old one
function ask_server_differs { function ask_server_differs {
echo echo
@ -443,6 +473,11 @@ function main {
# Get the current server file, version and build # Get the current server file, version and build
load_script load_script
# Check if the server type differs from the one in the config
if [[ $existing_server_type != $server_type ]]; then
ask_server_differs
fi
# Gets the installed server info # Gets the installed server info
get_existing_server get_existing_server