Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Add a failsafe for server type change
Browse files Browse the repository at this point in the history
  • Loading branch information
jiriks74 committed Mar 2, 2023
1 parent 3563330 commit 353b49a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .msman/version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

EXTRA_SCRIPTS_VERSION="v2.0.1"
EXTRA_SCRIPTS_VERSION="v2.1.1"
37 changes: 36 additions & 1 deletion msman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 353b49a

Please sign in to comment.