Created
October 30, 2018 09:38
-
-
Save ConoHa/7836a7014398d3a8008aa5361da84899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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