Skip to content

Instantly share code, notes, and snippets.

@Lucxjo
Last active October 9, 2021 11:38
Show Gist options
  • Save Lucxjo/87dece8e3ed1e33d59a7aa1fddb6159f to your computer and use it in GitHub Desktop.
Save Lucxjo/87dece8e3ed1e33d59a7aa1fddb6159f to your computer and use it in GitHub Desktop.
A BASH script to update my full vanilla MC server. Will update OS packages as well as update plugins.
#!/bin/bash
get_latest_release_version() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
get_latest_release_file() {
version=$(get_latest_release_version "$1")
wget "https://github.com/$1/releases/download/$version/$2.jar"
}
echo "Updating server"
systemctl stop minecraft.service
apt-get update -y
apt-get upgrade -y
echo "Package upgrade done.\nNow changing to ./mc-serv"
cd ./mc-serv/
echo "What is the latest paper build number?"
read paper_build
rm server.jar
wget -O server.jar "https://papermc.io/api/v2/projects/paper/versions/1.17.1/builds/$paper_build/downloads/paper-1.17.1-$paper_build.jar"
echo "Server.jar updated. Starting Plugin update"
cd ./plugins
rm BetterSleeping.jar
get_latest_release_file "Nuytemans-Dieter/BetterSleeping" "BetterSleeping"
rm discord.jar
echo "What is the latest DiscordSRV version?"
read discord_version
wget -O discord.jar "https://github.com/DiscordSRV/DiscordSRV/releases/download/v$discord_version/DiscordSRV-Build-$discord_version.jar"
rm BlueMap.jar
echo "What is the latest BlueMap version?"
read bm_version
wget -O BlueMap.jar "https://github.com/BlueMap-Minecraft/BlueMap/releases/download/v$bm_version/BlueMap-$bm_version-spigot.jar"
systemctl start minecraft.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment