minecraft-minder/mineautoshutdown.sh
zyphlar 6d22b4d999 Update 3 files
- /minecraft.php
- /README.md
- /mineautoshutdown.sh
2023-01-27 01:21:18 +00:00

33 lines
832 B
Bash
Executable File

#!/bin/bash
DO_STATUS_URL="http://example.com/minecraft.php"
PASSWORD="your_password_here"
status=$(curl -s -X POST -F "action=status" "$DO_STATUS_URL?password=$PASSWORD")
if [[ $status == "active" ]]; then
players=$(python3 $(dirname $0)minestatus.py | jq ".players")
if [[ $players == 0 ]]; then
if [ ! -f "/tmp/minecount" ]; then
touch /tmp/minecount
fi
count=$(cat /tmp/minecount)
if [[ $count -gt 6 ]]; then
echo "players $players count $count, killing"
curl -s -X POST -F "action=off" "$DO_STATUS_URL?password=$PASSWORD"
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: $status"
fi