Skip to content

Instantly share code, notes, and snippets.

@ConoHa
Created October 30, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ConoHa/7836a7014398d3a8008aa5361da84899 to your computer and use it in GitHub Desktop.
Save ConoHa/7836a7014398d3a8008aa5361da84899 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
readonly MINECRAFT_DIR="/opt/minecraft_server"
readonly MINECRAFT_SERVICE="/etc/systemd/system/minecraft-server.service"
readonly backup_dir=$(ls ${MINECRAFT_DIR}/backup | sort -r | head -n 1)
if [ -z ${backup_dir} -o -e ${backup_dir} ]; then
echo "Error: Backup directory not found."
exit 1
fi
systemctl disable --now minecraft-server
rm -rf ${MINECRAFT_DIR}/[^backup]*
cp -r ${MINECRAFT_DIR}/backup/${backup_dir}/* ${MINECRAFT_DIR}
mv -f ${MINECRAFT_DIR}/minecraft-server.service ${MINECRAFT_SERVICE}
chown minecraft:minecraft -R ${MINECRAFT_DIR}
systemctl daemon-reload
systemctl enable --now minecraft-server
echo "Version down finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment