Skip to content

Instantly share code, notes, and snippets.

@BarronKane
Last active December 30, 2022 02:25
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 BarronKane/7dfcd5b3b805bf72e6d47f5a916512f2 to your computer and use it in GitHub Desktop.
Save BarronKane/7dfcd5b3b805bf72e6d47f5a916512f2 to your computer and use it in GitHub Desktop.
A minecraft server start script that syncs worlds between server installs. Works between windows/linux/mac/etc, but if on windows, the windows server must be the main as it can't read linux/osx partitions.
#!/bin/bash
set -e
world=<world-name>
main=<main server install>
new=<new server install>
mkdir -p "${main}/bak"
mkdir -p "${new}/bak"
if [ ! -d "${new}/${world}" ]
then
cp -R "${main}/${world}" "${new}/${world}"
mv "${main}/${world}" "${main}/bak/${world}-$(date +%Y%m%d%H%M%S)"
else
read -p "CHECK WORLD" -n1 -s
break
fi
if ! grep -q "eula=true" eula.txt; then
echo "Do you agree to the Mojang EULA available at https://account.mojang.com/documents/minecraft_eula ?"
read -N 1 -p "[y/n] " EULA
if [ "$EULA" = "y" ]; then
echo "eula=true" > eula.txt
echo
fi
fi
"jre/jdk8u312-b07-jre/bin/java" -javaagent:log4jfix/Log4jPatcher-1.0.0.jar -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -Xmx4096M -Xms4096M -jar forge-1.12.2-14.23.5.2855.jar nogui
cp -R "${new}/${world}" "${main}/${world}"
mv "${new}/${world}" "${new}/bak/${world}-$(date +%Y%m%d%H%M%S)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment