Skip to content

Instantly share code, notes, and snippets.

@tterrag1098
Created August 24, 2017 18:02
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 tterrag1098/d16a80c45836826ed5368ae25581fd9e to your computer and use it in GitHub Desktop.
Save tterrag1098/d16a80c45836826ed5368ae25581fd9e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Terminate running screen, if it exists
if screen -list | grep -q "botscreen"; then
echo "Terminating current bot instance"
screen -S botscreen -p 0 -X stuff "stop^M"
else
echo "No current bot instance found"
fi
# Parse API data to find file name of latest build
filename=$(curl -s http://ci.tterrag.com/job/MCBot/lastSuccessfulBuild/api/json | jq -r '.artifacts[0].fileName')
# Check if bot is up to date
if [ -e $filename ]; then
# If it is, do nothing
echo "Bot up to date!"
else
# Otherwise, delete and redownload
# Remove old bot jar
echo "Deleting old jar"
rm -f MCBot-*.jar
# Download new bot jar
echo "Downloading new file: $filename"
wget "http://ci.tterrag.com/job/MCBot/lastSuccessfulBuild/artifact/build/libs/$filename"
fi
# Start new bot instance
echo "Starting screen"
screen -dmS botscreen java -jar $filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment