2023-01-27 01:21:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-01-26 23:15:40 +00:00
|
|
|
DO_STATUS_URL="http://example.com/minecraft.php"
|
2023-01-26 23:43:47 +00:00
|
|
|
PASSWORD="your_password_here"
|
2023-01-27 01:21:18 +00:00
|
|
|
status=$(curl -s -X POST -F "action=status" "$DO_STATUS_URL?password=$PASSWORD")
|
2023-01-26 23:15:40 +00:00
|
|
|
|
2023-01-27 08:32:24 +00:00
|
|
|
if [[ $status == "running" ]]; then
|
|
|
|
players=$(python3 $(dirname $0)/minestatus.py | jq ".players")
|
2023-01-26 23:15:40 +00:00
|
|
|
|
|
|
|
if [[ $players == 0 ]]; then
|
|
|
|
|
2023-01-27 01:21:18 +00:00
|
|
|
if [ ! -f "/tmp/minecount" ]; then
|
|
|
|
touch /tmp/minecount
|
|
|
|
fi
|
|
|
|
|
2023-01-26 23:15:40 +00:00
|
|
|
count=$(cat /tmp/minecount)
|
|
|
|
|
|
|
|
if [[ $count -gt 6 ]]; then
|
|
|
|
echo "players $players count $count, killing"
|
2023-01-27 01:21:18 +00:00
|
|
|
curl -s -X POST -F "action=off" "$DO_STATUS_URL?password=$PASSWORD"
|
2023-01-26 23:15:40 +00:00
|
|
|
echo "0" > /tmp/minecount
|
|
|
|
else
|
|
|
|
echo $(($count+1)) > /tmp/minecount
|
|
|
|
echo "players $players count $count, waiting"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "players $players, resetting"
|
|
|
|
echo "0" > /tmp/minecount
|
|
|
|
fi
|
|
|
|
else
|
2023-01-27 01:21:18 +00:00
|
|
|
echo "not active: $status"
|
2023-01-26 23:15:40 +00:00
|
|
|
fi
|