sandstorm-server/AutoUpdater/check-manifest.sh

45 lines
2.1 KiB
Bash
Raw Normal View History

2021-04-24 08:09:22 +00:00
#!/bin/bash
2021-04-28 18:08:51 +00:00
rconlist=127.0.0.1:55555,127.0.0.1:44444,127.0.0.1:33333
rconpass=my_rcon_password
2021-04-30 06:34:16 +00:00
modio_api_key=my_modio_apikey_!NOT_OAuth2_KEY!
2021-04-30 07:00:16 +00:00
2021-04-28 18:08:51 +00:00
while true; do
TOTAL=0
sleep $(((RANDOM % 360) + 60))
for rconip in $(echo "${rconlist//,/ }"); do
PLAYERSCOUNT=$(rcon -a "$rconip" -p "$rconpass" listplayers | tail -n +3 | wc -l)
TOTAL=$(("$PLAYERSCOUNT" + "$TOTAL"))
done
2021-04-30 06:34:16 +00:00
#CHECKING NEW GAME VERSION
2021-04-28 18:08:51 +00:00
if [ $TOTAL -eq 0 ]; then
LOCALAPPVER=$(cat /opt/sandstorm-server.version)
REMOTEAPPVER=$(curl -s -X GET 'https://api.steamcmd.net/v1/info/581330' | jq -r -e '.data."581330".depots."581333".manifests.public')
EXITSTATUS=$?
if [ $EXITSTATUS -eq 0 ]; then
2021-04-30 06:34:16 +00:00
#CHECKING ISMC NEW VERSION
LOCALMODVER=$(cat /opt/sandstorm-mod.version)
2021-04-30 07:00:16 +00:00
REMOTEMODVER=$(curl -s -X GET "https://api.mod.io/v1/games/254/mods/150867?api_key=$modio_api_key" -H 'Accept: application/json' | jq -r -e .modfile.filehash.md5)
2021-04-30 06:34:16 +00:00
EXITSTATUS=$?
if [ $EXITSTATUS -eq 0 ]; then
if [[ ("$LOCALAPPVER" != "$REMOTEAPPVER" || "$LOCALMODVER" != "$REMOTEMODVER") ]]; then
echo "$REMOTEAPPVER" >/opt/sandstorm-server.version
echo "$REMOTEMODVER" >/opt/sandstorm-mod.version
2021-05-01 13:00:48 +00:00
for n in {1800..1}; do
2021-04-30 06:34:16 +00:00
for rconip in $(echo "${rconlist//,/ }"); do
2021-05-01 13:00:48 +00:00
if ((n / 60 == 0)); then
rcon -a "$rconip" -p "$rconpass" "say 'THE SERVER WILL BE RESTARTED IN $n seconds'"
elif ((n % 60 == 0)); then
rcon -a "$rconip" -p "$rconpass" "say 'THE SERVER WILL BE RESTARTED IN $((n / 60)) minutes'"
fi
2021-04-30 06:34:16 +00:00
sleep 1
done
done
#START OF BLOCK WHERE YOU CAN WRITE RESTART COMMANDS
/opt/restart-ins.sh
#END BLOCK WHERE YOU CAN WRITE RESTART COMMANDS
fi
2021-04-28 18:08:51 +00:00
fi
fi
fi
done