/[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.4 - (show annotations) (download)
Tue Dec 21 17:35:08 1999 UTC (19 years, 9 months ago) by fabian
Branch: MAIN
CVS Tags: eggdrop105020, eggdrop10503, eggdrop10403, eggdrop1_6_5, eggdrop105040, eggdrop1_6_6
Changes since 1.3: +2 -0 lines
Tothwolf's id-header

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23