/[cvs]/eggdrop1.6/scripts/botchk
ViewVC logotype

Contents of /eggdrop1.6/scripts/botchk

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Tue Oct 26 21:38:36 1999 UTC (19 years, 7 months ago) by fabian
Branch: MAIN
Changes since 1.2: +56 -29 lines
resync 940380771-940924890

1 #! /bin/sh
2 #
3 # new botchk (for eggdrop 1.1+)
4 #
5 # This is a script suitable for use in a crontab. It checks to make sure
6 # your bot is running. YOU NEED A SEPARATE CRON JOB FOR EACH BOT. If your
7 # bot isn't found, it'll try to start it back up.
8 #
9 # You'll need to edit this script for your bot.
10 #
11 # To check for your bot every 10 minutes, put the following line in your
12 # crontab:
13 # 0,10,20,30,40,50 * * * * /home/mydir/botchk
14 # And if you don't want to get email from crontab when it checks you bot,
15 # put the following in your crontab:
16 # 0,10,20,30,40,50 * * * * /home/mydir/botchk >/dev/null 2>&1
17 #
18
19 # change this to the directory you run your bot from:
20 botdir="/home/mydir/mybot"
21
22 # change this to the name of your bot's script in that directory:
23 botscript="mybot"
24
25 # change this to the nickname of your bot (capitalization COUNTS)
26 botname="Doofy"
27
28 # change this to the name of your bot's userfile (capitalization COUNTS)
29 userfile="Doofy.user"
30
31 ########## you probably don't need to change anything below here ##########
32
33 cd $botdir
34
35 # is there a pid file?
36 if test -r pid.$botname
37 then
38 # there is a pid file -- is it current?
39 botpid=`cat pid.$botname`
40 if `kill -CHLD $botpid >/dev/null 2>&1`
41 then
42 # it's still going -- back out quietly
43 exit 0
44 fi
45 echo ""
46 echo "Stale pid.$botname file, erasing..."
47 rm -f pid.$botname
48 fi
49
50 if test -r CANTSTART.$botname
51 then
52 if test -r $userfile || test -r $userfile~new || test -r $userfile~bak
53 then
54 echo ""
55 echo "Userfile found, removing check file 'CANTSTART.$botname'..."
56 rm -f CANTSTART.$botname
57 fi
58 fi
59
60 # test if we have run botchk previously and didn't find a userfile
61 if test ! -f CANTSTART.$botname
62 then
63 echo ""
64 echo "Couldn't find bot '$botname' running, reloading..."
65 echo ""
66 # check for userfile and reload bot if found
67 if test -r $userfile
68 then
69 # It's there, load the bot
70 ./$botscript
71 exit 0
72 else
73 if test -r $userfile~new
74 then
75 # Bot f*@!ed up while saving the userfile last time. Move it over.
76 echo "Userfile missing. Using last saved userfile..."
77 mv -f $userfile~new $userfile
78 ./$botscript
79 exit 0
80 else
81 if test -r $userfile~bak
82 then
83 # Userfile is missing, use backup userfile.
84 echo "Userfile missing. Using backup userfile..."
85 cp -f $userfile~bak $userfile
86 ./$botscript
87 exit 0
88 else
89 # Well, nothing to work with...
90 echo "No userfile. Could not reload the bot..."
91 echo "no userfile" > CANTSTART.$botname
92 exit 1
93 fi
94 fi
95 fi
96 fi
97
98 exit 0

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23