From 353b49a76d51ea80b452c5dbda80f8c119e8d66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 2 Mar 2023 20:35:23 +0100 Subject: [PATCH] Add a failsafe for server type change --- .msman/version.sh | 2 +- msman.sh | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.msman/version.sh b/.msman/version.sh index c23641c..3cec9c3 100644 --- a/.msman/version.sh +++ b/.msman/version.sh @@ -1,3 +1,3 @@ #!/bin/bash -EXTRA_SCRIPTS_VERSION="v2.0.1" +EXTRA_SCRIPTS_VERSION="v2.1.1" diff --git a/msman.sh b/msman.sh index 51e0bbd..f6b57ec 100755 --- a/msman.sh +++ b/msman.sh @@ -8,7 +8,7 @@ set -e # 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 @@ -132,6 +132,36 @@ function ask_version_differs { 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 function ask_server_differs { echo @@ -443,6 +473,11 @@ function main { # Get the current server file, version and build 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 get_existing_server