mirror of
https://github.com/kaboomserver/buildpack.git
synced 2024-10-01 20:53:00 +00:00
22 lines
631 B
Bash
Executable file
22 lines
631 B
Bash
Executable file
#!/bin/sh
|
|
while true; do
|
|
sleep 180
|
|
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
|
|
date="$(tail -1 $logfile | grep -oP '(?<=\[).*?(?=\])' | head -1 | date -f - +%s)"
|
|
if [ "$(( $(date +%s) - ${date:=$(date +%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
|