-
-
Save RoyCurtis/22c80f0b5bb4b84f446d to your computer and use it in GitHub Desktop.
Plugin update script
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
#!/bin/bash | |
# With many thanks to Robrotheram for this script | |
# https://gist.github.com/robrotheram/5ffac65aed7ba43a8425 | |
# PLUGINS THAT NEED THEIR URLS MANUALLY UPDATING: | |
# * Chairs | |
# * GPrism | |
# * DiscordSRV | |
# * SignShopExport | |
# * Skript | |
# * SQLibrary | |
# * Stables | |
# * TicketMaster | |
# * Titanic | |
# * WoodCutter | |
# * WorldEdit/WorldGuard | |
# * WorldBorder | |
# * zPermissions | |
# CONFIGURATION: | |
# Path to server directory. DO NOT LEAVE EMPTY! | |
SERVER=/home/minecraft/Beta | |
# Path to plugins directory. DO NOT LEAVE EMPTY! | |
PLUGINS=$SERVER/plugins | |
# Identity of this server's tmux session | |
IDENT=GBeta | |
# User agent for use with wget | |
UA="Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36" | |
# FUNCTIONS: | |
function onError | |
{ | |
if [ $? -ne 0 ]; then | |
echo -e "*** $1 ***" | |
exit 1 | |
fi | |
} | |
# Downloads a file to the given filename from the given URL | |
function getFile | |
{ | |
local file=$1 | |
local url=$2 | |
local tries=1 | |
while true; do | |
echo "* Attempt #$tries at downloading '$1' from '$2'" | |
wget --no-check-certificate --user-agent="$UA" --timeout=5 -O $1 $2 &> last.err | |
if [ $? -eq 0 ]; then | |
# Successful download; exit getFile | |
return 0 | |
elif [ $tries -lt 3 ]; then | |
# Unsuccessful download; retry up to 3 times | |
let tries++ | |
echo -e "*** Failure. Retrying download after 2 seconds..." | |
sleep 2 | |
else | |
echo -e "*** ERROR downloading $2\n\n" | |
cat last.err | |
echo -e "\n\n*** ERROR! Please review above log" | |
exit 1 | |
fi | |
done | |
} | |
# Copies a file to the given filename from the given path | |
function localFile | |
{ | |
local dest=$1 | |
local src=$2 | |
echo "* Copying local JAR '$1' from '$2'" | |
cp $2 ./$1 | |
} | |
# OPTIONS: | |
while test $# -gt 0 | |
do | |
case "$1" in | |
--skip-spigot) skipSpigot=true | |
;; | |
--skip-plugins) skipPlugins=true | |
;; | |
*) echo "[SKRIPT] Unknown param '$1'" | |
echo "Usage: updateServer.sh [OPTIONS]" | |
echo "" | |
echo " --skip-spigot Don't update (Paper)Spigot" | |
echo " --skip-plugins Don't update plugins" | |
exit 1 | |
;; | |
esac | |
shift | |
done | |
# SCRIPT: | |
# First, check if server is running | |
tmux has-session -t $IDENT 2> /dev/null | |
if [ "$?" -eq "0" ]; then | |
echo -e "*** The server can't update whilst it's still running! ***" | |
echo -e "Please do 'tmux attach -t ${IDENT}', safely stop the server with 'stop' and then CTRL+C when it says to." | |
exit 1 | |
fi | |
# Then begin the update | |
cd $SERVER | |
echo -e "[UPDATE] Working in directory $SERVER" | |
if [ -z $skipSpigot ]; then | |
echo -e "[UPDATE] Installing latest PaperSpigot..." | |
wget -O paperclip.jar https://ci.destroystokyo.com/job/PaperSpigot/lastSuccessfulBuild/artifact/paperclip.jar | |
onError "Could not download PaperSpigot; see above!" | |
fi | |
if [ -z $skipPlugins ]; then | |
echo -e "[UPDATE] Backing up old plugins..." | |
cd $PLUGINS | |
dt=$(date +%Y%m%d%H%M%S) | |
mkdir plugins_$dt | |
cp *.jar plugins_$dt/. | |
echo -e "[UPDATE] Deleting all plugins..." | |
rm *.jar | |
echo -e "[UPDATE] Beginning download of plugins..." | |
# ChairsReloaded | |
getFile Chairs.jar https://dev.bukkit.org/projects/chairsreloaded/files/2450200/download | |
# CraftBook | |
getFile CraftBook.jar http://ci.md-5.net/job/CraftBook/lastSuccessfulBuild/artifact/target/craftbook-3.9-SNAPSHOT.jar | |
# DiscordSRV | |
getFile DiscordSRV.jar https://ci.scarsz.me/job/DiscordSRV/lastSuccessfulBuild/artifact/target/DiscordSRV-Build-14.8-SNAPSHOT-89.jar | |
# Dynmap | |
getFile Dynmap.jar http://dynmap.us/builds/dynmap/dynmap-3.x-HEAD.jar | |
# Dynmap-Essentials | |
getFile Dynmap-Essentials.jar http://dynmap.us/builds/Dynmap-Essentials/Dynmap-Essentials-HEAD.jar | |
# EssentialsX | |
getFile EssentialsX.jar https://ci.drtshock.net/job/EssentialsX/lastSuccessfulBuild/artifact/Essentials/target/EssentialsX-2.0.1.jar | |
# GCleanroomGenerator | |
getFile GCleanroomGenerator.jar https://github.com/Gamealition/GCleanroomGenerator/releases/download/v1.0-1.11/CleanroomGenerator-1.0-1.11.jar | |
# GPrism | |
getFile GPrism.jar https://github.com/Gamealition/GPrism/releases/download/1.12-2.0.12/prism-1.12-2.0.12.jar | |
# GTicketMaster (Gamealition fork) | |
getFile GTicketMaster.jar https://github.com/Gamealition/GTicketMaster/releases/download/1.11-1.0.10/GTicketMaster-1.11-1.0.10.jar | |
# HappyPet | |
getFile HappyPet.jar https://github.com/Gamealition/HappyPet/releases/download/1.2-SNAPSHOT/HappyPet-1.2-SNAPSHOT.jar | |
# LWC | |
getFile LWC.jar http://ci.dmulloy2.net/job/LWC/lastSuccessfulBuild/artifact/core/target/LWC.jar | |
# Multiverse Suite | |
getFile Multiverse-Core.jar https://ci.onarandombox.com/job/Multiverse-Core/lastSuccessfulBuild/artifact/target/Multiverse-Core-2.6.0-SNAPSHOT.jar | |
getFile Multiverse-Portals.jar https://ci.onarandombox.com/job/Multiverse-Portals/lastSuccessfulBuild/artifact/target/Multiverse-Portals-2.5.2-SNAPSHOT.jar | |
getFile Multiverse-NetherPortals.jar https://ci.onarandombox.com/job/Multiverse-NetherPortals/lastSuccessfulBuild/artifact/target/Multiverse-NetherPortals-2.5.2-SNAPSHOT.jar | |
# SignPortals with villager fix | |
localFile Multiverse-SignPortals.jar /home/minecraft/Build/Multiverse/Multiverse-SignPortals.jar | |
# SignShop | |
getFile SignShop.jar https://dev.bukkit.org/projects/signshop/files/2432183/download | |
# NoCheatPlus | |
getFile NoCheatPlus.jar http://ci.md-5.net/job/NoCheatPlus/lastSuccessfulBuild/artifact/target/NoCheatPlus.jar | |
# PerWorldInventory | |
localFile PerWorldInventory.jar /home/minecraft/Build/PerWorldInventory/target/perworldinventory-1.9.0.jar | |
# ProtocolLib | |
getFile ProtocolLib.jar http://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/modules/ProtocolLib/target/ProtocolLib.jar | |
# SignShopExport | |
getFile SignShopExport.jar https://github.com/Gamealition/SignShopExport/releases/download/1.11.2-1.1.0/SignShopExport-1.11.2-1.1.0.jar | |
# Skript | |
getFile Skript.jar https://github.com/bensku/Skript/releases/download/dev25/Skript.jar | |
# SQlibrary | |
getFile SQLibrary.jar https://dev.bukkit.org/projects/sqlibrary/files/767049/download | |
# Stables | |
getFile Stables.jar https://dev.bukkit.org/projects/stables/files/2373754/download | |
# Titanic | |
getFile Titanic.jar https://github.com/Gamealition/Titanic/releases/download/1.11-1.0.0/Titanic-1.11-1.0.0.jar | |
# VanishNoPacket | |
getFile VanishNoPacket.jar http://h.cnaude.org:8081/job/VanishNoPacket/lastSuccessfulBuild/artifact/target/VanishNoPacket.jar | |
# Vault | |
getFile Vault.jar https://dev.bukkit.org/projects/vault/files/894359/download | |
# WoodCutter | |
getFile WoodCutter.jar https://github.com/enjikaka/WoodCutter/releases/download/v1.5.0/WoodCutter-1.5.0-SNAPSHOT.jar | |
# WorldBorder | |
getFile WorldBorder.jar https://dev.bukkit.org/projects/worldborder/files/2415838/download | |
# WorldEdit | |
getFile WorldEdit.jar http://builds.enginehub.org/job/worldedit/9819/download/worldedit-bukkit-6.1.8-SNAPSHOT-dist.jar | |
# WorldGuard | |
getFile WorldGuard.jar http://builds.enginehub.org/job/worldguard/9824/download/worldguard-legacy-6.2.2-SNAPSHOT-dist.jar | |
# zPerms (GPermissions) | |
getFile zPermissions.jar https://github.com/Gamealition/GPermissions/releases/download/2.0-1.12pre/zPermissions-2.0-1.12pre.jar | |
rm last.err | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment