Skip to content

Instantly share code, notes, and snippets.

@rubenwardy rubenwardy/runserver.sh
Last active May 21, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.