initial version of automation script

This commit is contained in:
John Grosh 2020-11-04 18:56:10 -05:00
parent be4f235071
commit cebdbc3aa5
1 changed files with 35 additions and 0 deletions

35
scripts/run_jmusicbot.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/sh
# This will have this script check for a new version of JMusicBot every
# startup (and download it if the latest version isn't currently downloaded)
DOWNLOAD=true
# This will cause the script to run in a loop so that the bot auto-restarts
# when you use the shutdown command
LOOP=true
download() {
if [ $DOWNLOAD == true ]; then
URL=$(curl -s https://api.github.com/repos/jagrosh/MusicBot/releases/latest \
| grep -i browser_download_url.*\.jar \
| sed 's/.*\(http.*\)"/\1/')
FILENAME=$(echo $URL | sed 's/.*\/\([^\/]*\)/\1/')
if [ -f $FILENAME ]; then
echo "Latest version already downloaded (${FILENAME})"
else
curl -L $URL -o $FILENAME
fi
fi
}
run() {
java -Dnogui=true -jar $(ls -t JMusicBot* | head -1)
}
while
download
run
$LOOP
do
continue
done