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

Annotation of /eggdrop1.7/scripts/botchk

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


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Wed Aug 25 01:02:21 2004 UTC (15 years, 1 month ago) by wcc
Branch: MAIN, eggdrop
CVS Tags: eggdrop1_7, HEAD
Changes since 1.1: +0 -0 lines
* Starting 1.7 tree based off of 1.6.18 CVS as of August 24, 2004.

1 wcc 1.1 #! /bin/sh
2     #
3     # botchk
4     #
5     # $Id: botchk,v 1.6 2002/02/27 18:21:46 guppy Exp $
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/mybot/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/mybot/botchk >/dev/null 2>&1
19     #
20    
21     # change this to the directory you run your bot from (capitalization COUNTS):
22     botdir="/home/mydir/mybot"
23    
24     # change this to the name of your bot's config file (capitalization COUNTS):
25     botscript="mybot"
26    
27     # change this to the botnet-nick of your bot (capitalization COUNTS):
28     botname="LamestBot"
29    
30     # change this to the name of your bot's userfile (capitalization COUNTS):
31     userfile="LamestBot.user"
32    
33     # change this to the name of your bot's pidfile (capitalization COUNTS):
34     pidfile="pid.LamestBot"
35    
36     ########## you probably don't need to change anything below here ##########
37    
38     cd $botdir
39    
40     # is there a pid file?
41     if test -r $pidfile
42     then
43     # there is a pid file -- is it current?
44     botpid=`cat $pidfile`
45     if `kill -CHLD $botpid >/dev/null 2>&1`
46     then
47     # it's still going -- back out quietly
48     exit 0
49     fi
50     echo ""
51     echo "Stale $pidfile file, erasing..."
52     rm -f $pidfile
53     fi
54    
55     if test -r CANTSTART.$botname
56     then
57     if test -r $userfile || test -r $userfile~new || test -r $userfile~bak
58     then
59     echo ""
60     echo "Userfile found, removing check file 'CANTSTART.$botname'..."
61     rm -f CANTSTART.$botname
62     fi
63     fi
64    
65     # test if we have run botchk previously and didn't find a userfile
66     if test ! -f CANTSTART.$botname
67     then
68     echo ""
69     echo "Couldn't find bot '$botname' running, reloading..."
70     echo ""
71     # check for userfile and reload bot if found
72     if test -r $userfile
73     then
74     # It's there, load the bot
75     ./$botscript
76     exit 0
77     else
78     if test -r $userfile~new
79     then
80     # Bot f*@!ed up while saving the userfile last time. Move it over.
81     echo "Userfile missing. Using last saved userfile..."
82     mv -f $userfile~new $userfile
83     ./$botscript
84     exit 0
85     else
86     if test -r $userfile~bak
87     then
88     # Userfile is missing, use backup userfile.
89     echo "Userfile missing. Using backup userfile..."
90     cp -f $userfile~bak $userfile
91     ./$botscript
92     exit 0
93     else
94     # Well, nothing to work with...
95     echo "No userfile. Could not reload the bot..."
96     echo "no userfile" > CANTSTART.$botname
97     exit 1
98     fi
99     fi
100     fi
101     fi
102    
103     exit 0

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23