Created
August 24, 2017 18:02
-
-
Save tterrag1098/d16a80c45836826ed5368ae25581fd9e to your computer and use it in GitHub Desktop.
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 | |
# 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