Last active
March 9, 2022 00:55
-
-
Save rubenwardy/6dd980257407b48db89694bff08641f2 to your computer and use it in GitHub Desktop.
Auto-restart, log per season, email on crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd ~/.minetest | |
mkdir -p logs_ctf | |
function mailme() { | |
echo "To: rw@rubenwardy.com" > mail.txt | |
echo "Subject: CTF server crashed" >> mail.txt | |
echo "From: minetest@rubenwardy.com" >> mail.txt | |
echo "" >> mail.txt | |
tail -n 5 $1 >> mail.txt | |
tail "======" >> mail.txt | |
tail -n 300 $1 >> mail.txt | |
sendmail -vt < mail.txt | |
} | |
while true | |
do | |
DATE=$(date +%Y_%m_%d_%H_%M_%S) | |
echo "----------------------" >>$MOREDEBUG | |
echo "Server restarted at "`date` >>$MOREDEBUG | |
echo "----------------------" >>$MOREDEBUG | |
~/minetest_stable/bin/minetestserver \ | |
--logfile logs_ctf/debug_$DATE.txt \ | |
--world ./worlds/ctf \ | |
--gameid capturetheflag \ | |
--config minetest_ctf.conf || mailme logs_ctf/debug_$DATE.txt | |
sleep 10 | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment