| View previous topic :: View next topic |
| Author |
Message |
dragu Voice
Joined: 31 Jan 2009 Posts: 3
|
Posted: Sat Jan 31, 2009 9:00 pm Post subject: Autostart with init.d |
|
|
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 and sorry if i posted this in
the wrong section of the forum. |
|
| Back to top |
|
 |
Callisto Halfop
Joined: 13 Mar 2005 Posts: 86
|
Posted: Sun Feb 01, 2009 2:35 pm Post subject: |
|
|
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 |
|
 |
dragu Voice
Joined: 31 Jan 2009 Posts: 3
|
Posted: Sun Feb 01, 2009 7:34 pm Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
incith Master

Joined: 23 Apr 2005 Posts: 275 Location: Canada
|
Posted: Sun Feb 01, 2009 8:13 pm Post subject: |
|
|
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 |
|
 |
dragu Voice
Joined: 31 Jan 2009 Posts: 3
|
Posted: Sun Feb 01, 2009 8:21 pm Post subject: |
|
|
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 |
|
 |
|