Skip to content

Instantly share code, notes, and snippets.

@rubenwardy
Last active March 9, 2022 00:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/6dd980257407b48db89694bff08641f2 to your computer and use it in GitHub Desktop.
Save rubenwardy/6dd980257407b48db89694bff08641f2 to your computer and use it in GitHub Desktop.
Auto-restart, log per season, email on crash
#!/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