/me to: please include a startstop script

Here's my version of the start stop script

----------------------------------
#!/bin/sh
### BEGIN INIT INFO
# Provides:          gozerbot
# Required-Start:    $local_fs $remote_fs $network $named
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the Gozerbot IRC robot
# Description:       missing
### END INIT INFO
#
# Author: Tomas Pospisek <[email protected]>
#
#Based on /usr/share/gozerbot/gozerbot.cron

NAME=runbot
DESC="Gozerbot IRC robot"
RUNUSER=ircbot
HOMEDIR=/home/$RUNUSER/.gozerbot
PIDFILE=$HOMEDIR/gozerbot.pid
LOGFILE=/var/log/gozerbot.log

cd $HOMEDIR

PID=`cat $PIDFILE`

status()
{
        # pgrep doesn't seem to work with "-s $PID" under vserver? WTF?
        #test -r $PIDFILE && pgrep -s $PID runbot >/dev/nul"
        test -r $PIDFILE && ps auxw | grep -v grep | grep runbot | grep -q -s " $PID 
"
}

stop()
{
        if status
        then
                kill -CHLD $PID # doesn't seem to have any effect
                sleep 1
                kill -KILL $PID
        fi
}

start()
{
        status && exit 1 # allready running
        su $RUNUSER -c "$NAME >/var/log/gozerbot.log 2>&1 &"
}

case "$1" in
start)
        echo -n "Starting $DESC: $NAME"
        start
        case "$?" in
                0) echo "." ; exit 0 ;;
                1) echo " (already running)." ; exit 0 ;;
                *) echo " (failed)." ; exit 1 ;;
        esac
        ;;
stop)
        echo -n "Stopping $DESC: $NAME"
        stop
        case "$?" in
                0) echo "." ; exit 0 ;;
                1) echo " (not running)." ; exit 0 ;;
                *) echo " (failed)." ; exit 1 ;;
        esac
        ;;
restart|force-reload|reload)
        echo -n "Restarting $DESC: $NAME"
        stop
        start
        ;;
status)
        echo -n "Status of $DESC service: "
        status
        case "$?" in
                0) echo "running." ; exit 0 ;;
                1) echo "not running." ; exit 3 ;;
        esac
        ;;
*)
echo "Usage: /etc/init.d/gozerbot {start|stop|reload|force-reload|restart|status}" >&2
        exit 1
        ;;
esac
----------------------------------

*t



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to