Added a new update function

This commit is contained in:
N07070 2014-08-01 14:03:00 +02:00
parent 997b2db02c
commit d1bd69ba18
3 changed files with 34 additions and 1 deletions

View File

@ -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

1
update.txt Normal file
View File

@ -0,0 +1 @@
1.12

1
version.txt Normal file
View File

@ -0,0 +1 @@
0.5