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