-
Notifications
You must be signed in to change notification settings - Fork 33
/
autorun-ng
executable file
·91 lines (74 loc) · 3.38 KB
/
autorun-ng
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
# CircleMUD 2.0 autorun script
# Originally by Fred C. Merkel
# Copyright (c) 1993 The Trustees of The Johns Hopkins University
# All Rights Reserved
# See license.doc for more information
# Modifed by Christopher Dickey, Rift, Dunkelzahn, Demise, and Root.
# (c)2001 The AwakeMUD Consortium
# converted to bash by John Watson, June 22 1999.
# https://github.com/TempusMUD/Tempuscode/blob/master/bin/autorun
# Adapted to AwakeMUD CE by Finster
# If .fastboot exists, the script will sleep for only 5 seconds between reboot
# attempts. If .killscript exists, the script commit suicide (and remove
# .killscript). If pause exists, the script will repeatedly sleep for
# 60 seconds and will not restart the mud until pause is removed.
PORT=4000
DATE=$(date -u +"%Y-%m-%dT%H%M%SZ")
rm -f .killscript
while [ ! -e .killscript ]; do
rm -f pause
echo "autoscript starting game $DATE" >> syslog
bin/awake $PORT ~/AwakeMUD/lib > syslog 2>&1 &
PID=$!
echo $PID > ~/.awake.pid
wait $PID
RESULT=$?
rm ~/.awake.pid
tail -500 syslog >> log/crashlog
fgrep "self-delete" syslog >> log/delete
fgrep "Running" syslog >> log/restarts
fgrep "advanced" syslog >> log/levels
fgrep "equipment lost" syslog >> log/rentgone
fgrep "usage" syslog >> log/usage
fgrep "CONNLOG" syslog >> log/connlog
fgrep "MISCLOG" syslog >> log/misclog
fgrep "SYSLOG" syslog >> log/syslog
fgrep "WIZLOG" syslog >> log/wizlog
fgrep "DEATHLOG" syslog >> log/deathlog
fgrep "CHEATLOG" syslog >> log/cheatlog
fgrep "Bad PW" syslog >> log/badpws
mv syslog log/$DATE-system.log
if [ $RESULT -gt "128" ]; then
# We died as a result of a signal here: this pretty much means a segfault
if [ ! -x crash_report.sh ]; then
echo "A crash was detected but the crash report permissions were wrong." | mailx -s "AwakeMUD CE CRASH REPORT" $DEVS
elif [ ! -e ./lib/core ]; then
echo "A crash was detected but no core file was made." | mailx -s "AwakeMUD CE CRASH REPORT" $DEVS
else
./crash_report.sh lib/core log/$DATE-system.log >log/$DATE-crashreport.txt
mv lib/core log/$DATE-core
cat log/$DATE-crashreport.txt | mailx -s "AwakeMUD CE CRASH REPORT" $DEVS
fi
# Check to see if the mud ever actually started. If the mud
# never came up, we have a crash loop and need to stop the mud
# until someone comes and rescues it
if ! fgrep "Entering game loop" log/$DATE-system.log; then
touch pause
fi
elif [ -e .killscript ]; then
# Peaceful process death - permadeath
echo "autoscript killed" `udate` >> syslog
rm .killscript
exit
else
# Peaceful process death - a reboot is desired
echo "Reboot requested." | mailx -s "AwakeMUD CE Reboot Notification" $DEVS
fi
sleep 5
while [ -r pause ]; do
# Pause while the pause file still exists
sleep 5
done
done
echo "autoscript ending" $DATE >> syslog