Update mineautoshutdown.sh
This commit is contained in:
parent
04c5d06301
commit
8d97a4b40a
|
@ -15,14 +15,13 @@
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
DO_STATUS_URL="http://example.com/minecraft.php"
|
STATUS_URL="http://example.com/minecraft.php"
|
||||||
PASSWORD="your_password_here"
|
PASSWORD="your_password_here"
|
||||||
status=$(curl -s -X POST -F "action=status" "$DO_STATUS_URL?password=$PASSWORD")
|
status=$(curl -s -X POST -F "action=status" "$STATUS_URL?password=$PASSWORD")
|
||||||
|
|
||||||
if [[ $status == "running" ]]; then
|
if [[ $status =~ "running" ]]; then
|
||||||
players=$(python3 $(dirname $0)/minestatus.py | jq ".players")
|
|
||||||
|
|
||||||
if [[ $players == 0 ]]; then
|
if [[ $status =~ "0 players" ]]; then
|
||||||
|
|
||||||
if [ ! -f "/tmp/minecount" ]; then
|
if [ ! -f "/tmp/minecount" ]; then
|
||||||
touch /tmp/minecount
|
touch /tmp/minecount
|
||||||
|
@ -31,15 +30,15 @@ if [[ $status == "running" ]]; then
|
||||||
count=$(cat /tmp/minecount)
|
count=$(cat /tmp/minecount)
|
||||||
|
|
||||||
if [[ $count -gt 6 ]]; then
|
if [[ $count -gt 6 ]]; then
|
||||||
echo "players $players count $count, killing"
|
echo "$status count $count, killing"
|
||||||
curl -s -X POST -F "action=off" "$DO_STATUS_URL?password=$PASSWORD"
|
curl -s -X POST -F "action=off" "$STATUS_URL?password=$PASSWORD"
|
||||||
echo "0" > /tmp/minecount
|
echo "0" > /tmp/minecount
|
||||||
else
|
else
|
||||||
echo $(($count+1)) > /tmp/minecount
|
echo $(($count+1)) > /tmp/minecount
|
||||||
echo "players $players count $count, waiting"
|
echo "$status count $count, waiting"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "players $players, resetting"
|
echo "$status, resetting"
|
||||||
echo "0" > /tmp/minecount
|
echo "0" > /tmp/minecount
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user