-
Notifications
You must be signed in to change notification settings - Fork 4
/
startup
executable file
·53 lines (42 loc) · 1.1 KB
/
startup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
# SETTINGS
ADMIN_EMAIL=$(sed -n '/admin:/{s/^.*admin: \(.*\)$/\1/;p}' sourcemud.conf)
PAUSE=$(expr 60 '*' 5)
BIN=$(test -x './sourcemud' && echo './sourcemud' || test -x './src/sourcemud' && echo './src/sourcemud')
LOG='sourcemud.log'
MAIL=$(test -x /usr/sbin/sendmail && echo /usr/sbin/sendmail || which sendmail)
# CODE
# no executable?
if test "x$BIN" = "x" ; then
echo "No executable found" >&2
exit 2
fi
# allow core files
ulimit -c unlimited
# run loop
while true ; do
# run MUD - exit on proper exit
if "$BIN" ; then
exit 0
fi
# find core file
CORE=$(ls core core.* 2>/dev/null)
if test -f "$CORE" ; then
# mail message
echo 'Source MUD Crash at' `date` > mail.txt
echo >> mail.txt
# log file
echo '50 lines of log:' >> mail.txt
test -f "$LOG" && tail -n 50 "$LOG" >> mail.txt
echo >> mail.txt
# backtrace
echo 'Backtrace:' >> mail.txt
echo 'backtrace' > gdb.cmds.txt
gdb "$BIN" "$CORE" -batch -x gdb.cmds.txt >> mail.txt
rm -f gdb.cmds.txt
# do mail
"$MAIL" -s 'Source MUD Crash' "$ADMIN_EMAIL" < mail.txt
fi
# pause before restart
sleep "$PAUSE"
done