minecraft-minder/mineautoshutdown.sh

27 lines
697 B
Bash
Raw Normal View History

2023-01-26 23:15:40 +00:00
DO_STATUS_URL="http://example.com/minecraft.php"
PASSWORD="your_password_here"
status=$(curl -s "$DO_STATUS_URL?action=status&password=$PASSWORD")
2023-01-26 23:15:40 +00:00
if [[ $status == "active" ]]; then
players=$(python3 minestatus.py | jq ".players")
if [[ $players == 0 ]]; then
count=$(cat /tmp/minecount)
if [[ $count -gt 6 ]]; then
echo "players $players count $count, killing"
curl -s "$DO_STATUS_URL?action=off&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
echo "not active"
fi