egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Autostart with init.d

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help
View previous topic :: View next topic  
Author Message
dragu
Voice


Joined: 31 Jan 2009
Posts: 3

PostPosted: Sat Jan 31, 2009 9:00 pm    Post subject: Autostart with init.d Reply with quote

Aight were just about to head for bed when i got the urge to do something
with the eggdrop bot that is running on my server. After having updated the
bot software to the latest version i got the urge to add it to the init.d so that
it would automaticly start when the machine was activated.

I understand if this might not be the right place for something like this but
would appriciate any comments about it so i know if it might work as the
idea was in my head for it to do.

Code:
#!/bin/sh
#
# Starts eggdrop script
#
# chkconfig: 345 94 06
# description: eggdrop is the world's most popular Open Source bot, designed under GNU license
# more information can be found at http://www.eggheads.org
MYDESC="eggdrop"
MYPATH=/home/user/eggdrop
MYNAME=user
MYLOCK=$MYNAME
DAEMON=$MYPATH/RunEggdrop.sh
MYPIDF=/var/run/$MYNAME.pid
MYCMND="$MYPATH/RunEggdrop.sh"

# Source function library.
. /etc/rc.d/init.d/functions

# Make sure the daemon directory is in the front of the path list
PATH=$MYPATH:$PATH

# See how we were called.
case "$1" in
  start)
        # Change to package directory so config paths can be relative
        cd $MYPATH || \
          { echo "$0: Can't cd to $MYPATH" ; exit 1 ; }
        # Make sure the daemon exists
        [ -f $DAEMON ] || \
          { echo "$0: Daemon not found: $DAEMON" ; exit 1 ; }
        # See if we are already running
        # Note: kill -0 _PID_
        #       returns true if process _PID_ is alive and accepting signals.
        [ -f $MYPIDF ] && kill -0 `cat $MYPIDF` && \
          { echo "$0: $MYPIDF exists and process is running" ; exit 1 ; }
        echo -n "Starting $MYDESC: "
        echo "$MYNAME "
        su -l -c "$MYCMND" user | tee $MYPIDF
        tail -1 $MYPIDF | cut -d'=' -f2 | cut -d' ' -f1 > $MYPIDF
        chown user.user $MYPIDF
        touch /var/lock/subsys/$MYLOCK
        ;;
  stop)
        echo -n "Shutting down $MYDESC: "
        echo -n "$MYNAME "
        killproc eggdrop
        rm -f $MYPIDF
        echo
        rm -f /var/lock/subsys/$MYLOCK
        ;;
  status)
        status $MYNAME
        ;;
  restart)
        $0 stop
        sleep 1
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit 0


The sh script which it calls to start the eggdrop is just a container of:
Code:
cd /home/user/eggdrop
./eggdrop config.conf


Any suggestions or comments would be most welcomed.
But now i'm going to let my brain rest Razz and sorry if i posted this in
the wrong section of the forum.
Back to top
View user's profile Send private message
Callisto
Halfop


Joined: 13 Mar 2005
Posts: 86

PostPosted: Sun Feb 01, 2009 2:35 pm    Post subject: Reply with quote

Hi, just wondering what is wrong with a good old fashioned crontab?
I dont mean to be picky or distrespectful, however isnt your shell script kinda re-inventing the wheel?
The only advantage I can see is the bot starts as soon as the box has started.
Regards
Back to top
View user's profile Send private message
dragu
Voice


Joined: 31 Jan 2009
Posts: 3

PostPosted: Sun Feb 01, 2009 7:34 pm    Post subject: Reply with quote

Well i sure don't have anything against the crontab solution, how ever that
direction does not ensure that it starts directly when the machine is on.
Personly also i try to keep as few things as possible in the cron section if
there are other ways to solve it.

Ceartingly i can admit that it might seem alot as that there shouldn't be any
need to do it in another way.

How ever it were mostly only a thought to have a way that it would start in
direct and simple way after say a power outage or something like that.

Anyhow i will be looking into this a bit more and if i'd might find a solution
where actually it would work. But suggestions and advice would always be
most welcomed. Smile
Back to top
View user's profile Send private message
incith
Master


Joined: 23 Apr 2005
Posts: 275
Location: Canada

PostPosted: Sun Feb 01, 2009 8:13 pm    Post subject: Reply with quote

I'd have to agree with just using cron. Set the timer to every minute if you must (I use 5 or 10 minute check).. your bot will start as soon as cron check runs, whether the machine is rebooted or not.

Just setup your botchk file and chmod +x it. Then (from shell) run crontab -e
Code:
# minute(0-59) hour(0-23) day(1-31) month(1-12) weekday(0-6,0=sun)
*/15 * * * * /home/incith/eggdrop/botchk.visitant 2>&1


Save & close file.

Guess I use 15 minutes. */1 would be every minute, etc.
_________________
; Answer a few unanswered posts!
Back to top
View user's profile Send private message
dragu
Voice


Joined: 31 Jan 2009
Posts: 3

PostPosted: Sun Feb 01, 2009 8:21 pm    Post subject: Reply with quote

Ehrm.. Yes that is ceartingly true that it would. How ever depending on the
timer and such dilemas it does not kick on right at the boot which is the
thing which i were looking to do. And also as i mentioned, i am not a big
fan over cron and tries to use it to a minimum.

No offence to those which like the solution for cron, it's just not my
cup of tea so to say. Anyhow guess will look it up to another direction
to find out if the things would work.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber