Skip to content

Instantly share code, notes, and snippets.

@tterrag1098

tterrag1098/start.sh

Created Aug 24, 2017
Embed
What would you like to do?
#!/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