#!/bin/sh while true; do sleep 420 logfile=$HOME/logs/latest.log if [ "$(env printf '\xFE' | nc -w 5 localhost 25565 | wc -m)" -eq 0 ]; then if [ -f "$logfile" ]; then if [ "$(tail -20 $logfile | grep -c 'ERROR]: Requested chunk')" -eq 1 ]; then rm -rf $HOME/worlds/ fi fi pkill -9 java elif [ -f "$logfile" ]; then if [ "$(( $(date +%s) - $(date -r $logfile +%s) ))" -gt 180 ]; then if [ "$(tail -20 $logfile | grep -c 'ERROR]: Requested chunk')" -eq 1 ]; then rm -rf $HOME/worlds/ fi pkill -9 java fi fi done