Guest User

update.sh

a guest
Oct 22nd, 2020
58
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. set -euf -o pipefail
  3.  
  4. cd /opt/minecraft/server/;
  5. /usr/bin/echo "Comparing Checksums";
  6. oldsum=$(/usr/bin/md5sum paperclip.jar | /usr/bin/awk '{print $1}');
  7. /usr/bin/echo "Download paperclip for comparison"
  8. /usr/bin/wget https://papermc.io/api/v1/paper/1.16.3/latest/download --output-document=paperclip.jar.tmp --no-cache;
  9. newsum=$(/usr/bin/md5sum paperclip.jar.tmp | /usr/bin/awk '{print $1}');
  10. /usr/bin/date;
  11.  
  12. if [[ "$oldsum" != "$newsum" ]]; then
  13.         /usr/bin/echo "Update Required";
  14.         /usr/bin/echo "Stopping Server";
  15.         /opt/minecraft/tools/mcrcon/mcrcon -H HOST -P MCRCON_PORT -p MCRCON_PASS stop || true;
  16.         /usr/bin/echo "Rolling paperclip.jar files";
  17.         /usr/bin/mv --force /opt/minecraft/server/paperclip.jar.2 paperclip.jar.3;
  18.         /usr/bin/mv --force /opt/minecraft/server/paperclip.jar.1 paperclip.jar.2;
  19.         /usr/bin/mv --force /opt/minecraft/server/paperclip.jar paperclip.jar.1;
  20.         /usr/bin/echo "Installing new paperclip.jar";
  21.         /usr/bin/mv --force /opt/minecraft/server/paperclip.jar.tmp /opt/minecraft/server/paperclip.jar
  22.         /usr/bin/echo "Set file permissions";
  23.         /usr/bin/chown minecraft:minecraft paperclip.jar;
  24.         /usr/bin/echo "Update Process Complete";
  25.     /usr/bin/date;
  26.         /usr/bin/echo "Starting Minecraft"
  27.         /usr/bin/systemctl start minecraft
  28.         exit 0;
  29. fi
  30. /usr/bin/echo "No Update Available"
  31. exit 0;
  32.  
RAW Paste Data