Created
August 3, 2021 05:17
-
-
Save rgregg/e0e50c4fec3bd5804697ccf5b5149ba3 to your computer and use it in GitHub Desktop.
Update Minecraft FTB/ATM6 docker containers to the latest version
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 | |
if [ $# -eq 0 ] | |
then | |
echo "No arguments supplied. Must specify the version for the upgrade." | |
exit 1 | |
fi | |
new_version=$1 | |
if test -f "./data/version.txt"; then | |
version=$(<./data/version.txt) | |
else | |
echo "No previous version found. Create ./data/version.txt with current version number." | |
exit 1 | |
fi | |
modpack_file=./modpacks/SIMPLE-SERVER-FILES-$new_version.zip | |
if test -f "$modpack_file"; then | |
echo "New modpack found: $modpack_file" | |
else | |
echo "Unable to locate modpack. Make sure the latest version is stored in $modpack_file". | |
exit 1 | |
fi | |
echo "Updating from $version to $new_version." | |
data_pattern=./data/FeedTheBeast/SIMPLE-SERVER-FILES | |
old_data=$data_pattern-$version | |
# Locate the name of the world for this server | |
input=$old_data/server.properties | |
level_name=world | |
while IFS='=' read -r field value | |
do | |
#echo "name: $field; value: $value" | |
if [ "$field" = "level-name" ]; then | |
level_name=$value | |
fi | |
done < $input | |
echo "Minecraft world level name: $level_name" | |
# Create a backup of the existing server | |
echo "Archiving $version..." | |
tar -zcf archive/backup-$version.tar.gz ./data | |
# Move configuration files to a temp folder | |
mkdir -p ./config | |
echo "Saving configuration files..." | |
cp $old_data/ops.json $old_data/whitelist.json $old_data/server.properties ./config/ | |
echo "Saving world $level_name files..." | |
cp -r $old_data/$level_name ./config/$level_name | |
# Remove previous server data folder | |
rm -rf ./data | |
# Recreate data folder and copy saved files | |
new_data=$data_pattern-$new_version | |
mkdir -p $new_data | |
mv ./config/ops.json ./config/whitelist.json ./config/server.properties $new_data/ | |
mv ./config/$level_name $new_data/$level_name | |
rm -r ./config | |
# Rewrite docker-compose.yaml file to use the new modpack version | |
echo $new_version >| ./data/version.txt | |
sed -i "s/SIMPLE-SERVER-FILES-$version.zip/SIMPLE-SERVER-FILES-$new_version.zip/" docker-compose.yaml | |
echo "Ready to relaunch server and finalize update." | |
echo "To get started, run docker-compose up -d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment