Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to update minecraft server to latest version, either snapshot or release
#!/bin/sh
# Can be snapshot or release
DEFAULTREVISION=release
# Pull out latest snapshot version
REVISION=${1-$DEFAULTREVISION}
REGEX="(?<=$REVISION\": \").*?[^\\\\](?=\")"
VERSION=`curl -silent "http://s3.amazonaws.com/Minecraft.Download/versions/versions.json" | grep -Po "$REGEX"`
if [ "$VERSION" = "" ]; then
echo "Invalid Version"; exit
fi
URL="https://s3.amazonaws.com/Minecraft.Download/versions/$VERSION/minecraft_server.$VERSION.jar"
echo "Version: " $VERSION
echo "URL: " $URL
# Download the latest version
curl -O $URL
# Symlink to the server jar
if [ -f "minecraft_server.jar" ]; then
rm minecraft_server.jar
fi
ln -s "minecraft_server.$VERSION.jar" minecraft_server.jar
@filiptronicek

This comment has been minimized.

Copy link

@filiptronicek filiptronicek commented May 20, 2020

Thanks, very useful!
I just would update the version url- https://launchermeta.mojang.com/mc/game/version_manifest.json is the new one

@xdaytona955

This comment has been minimized.

Copy link

@xdaytona955 xdaytona955 commented Sep 18, 2020

Sadly that script doesn't work anymore, Mojang changed the links and manifest file.

I wrote this simple python script to download the latest jar file (works as of 9/18/20):

import json, requests

manifestUrl = json.loads(requests.get("https://launchermeta.mojang.com/mc/game/version_manifest.json").content)

downloadUrl = json.loads(requests.get(manifestUrl["versions"][0]["url"]).content)["downloads"]["server"]["url"]

fileData = requests.get(downloadUrl)

with open("server.jar", "wb") as fileObject:
        fileObject.write(fileData.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.