buildpack/script/alivecheck

16 lines
382 B
Text
Raw Normal View History

#!/bin/sh
while true; do
2019-09-27 15:45:00 +03:00
sleep 420
2019-08-16 04:32:46 +03:00
logfile=$HOME/logs/latest.log
2019-11-30 18:18:45 +02:00
if [ -f "$logfile" ]; then
if [ "$(env printf '\xFE' | nc -w 5 localhost 25565 | wc -m)" -eq 0 ] ||
[ "$(( $(date +%s) - $(date -r $logfile +%s) ))" -gt 180 ]; then
2019-08-16 04:32:46 +03:00
if [ "$(tail -20 $logfile | grep -c 'ERROR]: Requested chunk')" -eq 1 ]; then
rm -rf $HOME/worlds/
fi
pkill -9 java
fi
fi
done