Skip to content

Instantly share code, notes, and snippets.

@thedava
Last active August 29, 2015 14:16
Show Gist options
  • Save thedava/d441f91dcad2cba6c361 to your computer and use it in GitHub Desktop.
Save thedava/d441f91dcad2cba6c361 to your computer and use it in GitHub Desktop.
Minecraft-Server Deployment Script
#!/bin/bash
svn_path="http://davahome-minecraft.svn/trunk/MinecraftInstance/"
live_folder="minecraft_instance"
backup_folder="__minecraft_instance"
export_folder="__export"
echo "Exporting from svn: "${svn_path}
# Remove old export folder if exists
if [[ -d ${export_folder} ]]; then
echo "Removing old export folder..."
rm -rf ${export_folder}
fi
# SVN export
echo "Starting export...."
svn export -q ${svn_path} ${export_folder}
echo "done!"
# LIVE folder switch
if [[ -d ${backup_folder} ]]; then
echo "Removing backup folder..."
rm -rf ${backup_folder}
echo "done!"
fi
if [[ -d ${live_folder} ]]; then
echo "Create backup of current live folder..."
mv ${live_folder} ${backup_folder}
echo "done!"
fi
echo "Create new live folder from export..."
mv ${export_folder} ${live_folder}
echo "done!"
# Restore savegame folder
echo "Restore savegame? <y/n>"
read restore_savegame
if [[ ${restore_savegame} == "y" ]]; then
cp ${backup_folder}/world ${live_folder}/ -R
echo "Restored!"
fi
# Dh Minecraft specific notations
echo "Preparing instance..."
if [[ -f "${live_folder}/ServerStart.sh" ]]; then
echo "Set +x for start script"
chmod +x ${live_folder}/ServerStart.sh
fi
if [[ -d "${live_folder}/_server" ]]; then
echo "Applying special server changes..."
cp ${live_folder}/_server/* ${live_folder}/ -R
rm -rf ${live_folder}/_server
echo "done!"
fi
echo "Deployment done!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment