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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#!/bin/bash
#
# This is a replacement for the crosserv.pl perl script.,
# No point in using perl for such a simple task.
# This script 'archives' relevent crash information in some
# directory, and sends a mail message informing people of
# the crash. The mail message includes the backtrace info.
# This was originally written by Bob Tanner, modified by Mark Wedel
# NOTE: Before using this script, some of the variables at the top
# will need to be changed. Also note that make install will not
# overwrite this file if it already exists.
# Note2: This script uses $HOME/.gdbweb as the script used to
# feed to gdb. This file should be like:
# echo \n(gdb) Executing command "bt full":\n\n
# bt full
# echo \n(gdb) Executing command "up" (20 times):\n\n
# up
# up (repeat 18 more times)
#
# due to variable substitution, we need all of this for it to
# work.
prefix="/usr/games/crossfire"
exec_prefix="${prefix}"
bindir="${exec_prefix}/bin"
CROSSFIRE="$bindir/crossfire"
# This can include multiple people, just seperate them by commas.
MAILTO="master@hugin"
# This is the program used to send out the mail message. It needs
# to support the -s (subject) option. On SysV systems, this may be
# /usr/ucb/mail.
MAIL=/usr/bin/Mail
# URL that contains the publicly available crash information.
# Thi is only used in the mail message that is sent out to make it
# easier for people to go to the web site.
URL="http://www.metalforge.org/core/"
MAXRESTART=500
# This is the publicly available directory that will contain the log
# and core files.
HTMLDIR="$HOME/public_html"
# This is where the source resides on the server. This is used to
# get better information on backtraces.
SRCDIR="/export/home/crossfire/crossfire-CVS"
ulimit -c unlimited
logcount=0
if [ ! -d $HTMLDIR ]; then
echo "$HTMLDIR does not exist. Aborting."
exit 1
fi
while [ ! "$logcount"x = "$MAXRESTART"x ]; do
echo "Starting Crossfire `date` for the $logcount time..." 1>$HTMLDIR/server.$$.$logcount.log 2>&1
$CROSSFIRE -d 2>>$HTMLDIR/server.$$.$logcount.log 1>&2
if [ -f core ] ; then
echo "<html><pre>" > $HTMLDIR/backtrace.$$.$logcount.html
/usr/bin/gdb -batch -d $SRCDIR -x $HOME/.gdbweb $CROSSFIRE core >> $HTMLDIR/backtrace.$$.$logcount.html
if [ $? -ne 0 ]; then
echo "gdb failed for some reaons." >> $HTMLDIR/backtrace.$$.$logcount.html
fi
echo "</pre></html>" >> $HTMLDIR/backtrace.$$.$logcount.html
mv core $HTMLDIR/core.$$.$logcount
if [ $? -ne 0 ]; then
echo "Could not move core file."
break
fi
/usr/bin/gzip -9 $HTMLDIR/core.$$.$logcount &
/usr/bin/gzip -9 $HTMLDIR/server.$$.$logcount.log &
/bin/chmod 644 $HTMLDIR/core*.gz
echo "Crossfired crashed at `date`. Crash instance is $logcount." > /tmp/crossloop.web.$$
echo "The core files and server log can be found at" >> /tmp/crossloop.web.$$
echo "$URL/backtrace.$$.$logcount.html" >> /tmp/crossloop.web.$$
echo "$URL/core.$$.$logcount.gz" >> /tmp/crossloop.web.$$
echo "$URL/server.$$.$logcount.log.gz" >> /tmp/crossloop.web.$$
cat /tmp/crossloop.web.$$ $HTMLDIR/backtrace.$$.$logcount.html | $MAIL -s "Crossfire crashed." $MAILTO
@RM@ /tmp/crossloop.web.$$
else
# may or may not want to keep the old one around.
#@RM@ $HTMLDIR/backtrace.$$.$logcount.html
# Need some statement here for the else/fi to work.
/bin/false
fi
logcount=`expr $logcount + 1`
sleep 10s
done
|