Created
July 10, 2019 20:32
-
-
Save einarjh/482ad1c6f0f727f072ec3b4af05277b4 to your computer and use it in GitHub Desktop.
A script that downloads the latest Minecraft snapshot and makes it available for Multicraft. Requires wget and jq
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
minecraft@minecraft:~$ cat bin/getlatestminecraftsnapshot.bash | |
#!/bin/bash | |
# A quick and dirty script to fetch the latest minecraft snapshot for multicraft | |
cd ~/multicraft/jar | |
VERSION_URL="https://launchermeta.mojang.com/mc/game/version_manifest.json" | |
LATEST_VER=$(wget -qO - "${VERSION_URL}" | jq -r .latest.snapshot) | |
# Our CURRENT_VER is stored in current_ver and we don't need no stinking error messages | |
source current_snap > /dev/null 2>&1 | |
# Check if we need a new minecraft_server.jar | |
if [ ! "${CURRENT_VER:-1}" = "${LATEST_VER}" ] || [ ! -f "minecraft_server.${LATEST_VER}.jar" ]; then | |
LATEST_MANIFEST=$(wget -qO - "${VERSION_URL}" | jq -r --arg VERSION_TARGET "${LATEST_VER}" '.versions | .[] | select(.id==$VERSION_TARGET) | .url') | |
LATEST_SERVER_URL=$(wget -qO - "${LATEST_MANIFEST}" | jq -r .downloads.server.url) | |
wget -q "${LATEST_SERVER_URL}" -O "minecraft_server.${LATEST_VER}.jar" && echo "CURRENT_VER=${LATEST_VER}" > current_snap | |
cp "minecraft_server.jar.conf" "minecraft_server.${LATEST_VER}.jar.conf" | |
sed -i "s/Default Minecraft Server/Minecraft ${LATEST_VER}/" "minecraft_server.${LATEST_VER}.jar.conf" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment