Created
September 4, 2018 02:46
-
-
Save ConoHa/f4684b10d28e5569b07bfadc7ea19e10 to your computer and use it in GitHub Desktop.
verdown_to_1.13.0.sh
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 MINECRAFT_OLD_VERSION="1.13.0" | |
readonly backup_dir=$(ls ${MINECRAFT_DIR}/backup | grep ${MINECRAFT_OLD_VERSION} | 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