From d1bd69ba18f583f87a83b07d66d705e0a2e89a98 Mon Sep 17 00:00:00 2001 From: N07070 Date: Fri, 1 Aug 2014 14:03:00 +0200 Subject: [PATCH] Added a new update function --- start_server.sh | 33 ++++++++++++++++++++++++++++++++- update.txt | 1 + version.txt | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 update.txt create mode 100644 version.txt diff --git a/start_server.sh b/start_server.sh index d7c808c..9f03deb 100755 --- a/start_server.sh +++ b/start_server.sh @@ -12,6 +12,35 @@ echo "======================================================" sleep 2 clear +#This function checks for an update, comparing the version numbers of to files. +function check_update(){ + echo ">> I am now going to check for an update..." + wget https://raw.githubusercontent.com/007N/Minecraft-Startup-Script/master/update.txt + update_version=cat update.txt + version=cat version.txt + if [version < update_version ]; then + read -p ">> Version $update_version is avaible. Would you like to update ? ( y/n )" choice + while [ -z $choice ] || [ $choice != 'y' ] || [ $choice != 'n']; do + case $choice in + "y") + echo ">> I will now stop the script, update, and reload the script !" + #Need to make the upate script. + # Update the version.txt file, delete the file, download the new one, re-run it. + ;; + "n") + echo ">> You will miss an update,possibly with security fixes, and be asked next time you start the server." + ;; + *) + echo ">> Please entre a valid choice : y or n ." + ;; + esac + done + + else + echo ">> You have the last availaible update !" + fi +} + #This function runs to check if the directory has everything the server needs. function first_run() { if [[ -d Backups/ ]] && [[ -e "minecraft_server.jar" ]] && [[ -e "server-icon.png" ]]; then @@ -31,6 +60,7 @@ function first_run() { #This function runs the server. function run_server() { + check_update first_run echo ">> I'm removing the old backup" rm -r Backups/Backup.tar.gz @@ -49,6 +79,7 @@ function run_server() { echo ">> ArrĂȘt du serveur fini. " } +#This is really easy to understand. function show_help() { echo ">> Welcome to the server installation script." echo ">> This script supports one option:" @@ -69,5 +100,5 @@ else echo ">> * You can skip this part as of now by strating the script with the -k argument." read -p "Press [Enter] key to start the script..." fi - + run_server diff --git a/update.txt b/update.txt new file mode 100644 index 0000000..809bdcb --- /dev/null +++ b/update.txt @@ -0,0 +1 @@ +1.12 diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..ea2303b --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.5 \ No newline at end of file