From b23fb933668851eb788aa46ef3572c1e1456f632 Mon Sep 17 00:00:00 2001 From: jtcressy Date: Tue, 15 Mar 2016 01:05:37 -0600 Subject: [PATCH 1/3] Undid method of pulling spigot_server.jar rm -f $SERVER was a bad idea, as it deletes the server file regardless of whether wget is able to download a new one. If you keep a copy of spigot_server in the server directory, wget will fail if it's unable to pull the file and it wont delete what you already have. --- minecraft-server/start-minecraft.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index dff0536a..0c564edd 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -62,7 +62,8 @@ case "$TYPE" in ;; esac - rm -f $SERVER + #BAD Idea + #rm -f $SERVER wget -q https://getspigot.org$URL ;; From a1ead0634efec239f5d56f706c9a6bb4252f21d0 Mon Sep 17 00:00:00 2001 From: jtcressy Date: Tue, 15 Mar 2016 13:09:28 -0600 Subject: [PATCH 2/3] [mc] New method of downloading newer spigot server executable. using double pipe "||", bash will continue to the next statement if the first statement returns false or has an error. Using the -N option, wget will overwrite the file if it is newer. So, if the -O option was used, and both wget commands failed (both http and https were down) then wget would overwrite the file with a 0 byte copy and effectively delete it. -N works better in this case, since wget will not overwrite it with an empty file if it can't download it. --- minecraft-server/start-minecraft.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 0c564edd..2848139f 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -62,9 +62,8 @@ case "$TYPE" in ;; esac - #BAD Idea - #rm -f $SERVER - wget -q https://getspigot.org$URL + #attempt https, and if it fails, fallback to http and download that way. Display error if neither works. + wget -q -N spigot_server.jar https://getspigot.org$URL || (echo "Falling back to http, unable to contact server using https..." && wget -q -N spigot_server.jar http://getspigot.org$URL) || echo "Unable to download new copy of spigot server" ;; From a195583990aec1892c0ef268a0a740a8f3df9fd5 Mon Sep 17 00:00:00 2001 From: jtcressy Date: Wed, 16 Mar 2016 21:18:31 -0600 Subject: [PATCH 3/3] Cleaned Up Code per itzg's suggestion Replaced hardcoded spigot_server.jar with $SERVER and broke up the line to make it more readable. --- minecraft-server/start-minecraft.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 2848139f..e75114c6 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -63,7 +63,10 @@ case "$TYPE" in esac #attempt https, and if it fails, fallback to http and download that way. Display error if neither works. - wget -q -N spigot_server.jar https://getspigot.org$URL || (echo "Falling back to http, unable to contact server using https..." && wget -q -N spigot_server.jar http://getspigot.org$URL) || echo "Unable to download new copy of spigot server" + wget -q -N $SERVER https://getspigot.org$URL || \ + (echo "Falling back to http, unable to contact server using https..." && \ + wget -q -N $SERVER http://getspigot.org$URL) || \ + echo "Unable to download new copy of spigot server" ;;