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: Select all
#!/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
Code: Select all
cd /home/user/eggdrop
./eggdrop config.conf
But now i'm going to let my brain rest and sorry if i posted this in
the wrong section of the forum.