Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 67 lines (61 sloc) 1.75 KB
#!/bin/bash
# $Id$
# $Revision$
# $Author$
# $Date$
#
# Copyright (c) 2003 Mirco 'meebey' Bauer <mail@meebey.net>
#
# Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON_PATH=/home/meebey/phpbitch
DAEMON=$DAEMON_PATH/phpbitch_wrapper
NAME=phpbitch
DESC="IRC service bot daemon"
QUIET=--quiet
test -x $DAEMON || exit 0
set -e
cd $DAEMON_PATH
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
echo > $DAEMON_PATH/phpbitch_php.log
start-stop-daemon --start $QUIET -m --pidfile $DAEMON_PATH/$NAME.pid \
--exec $DAEMON &
# overwriting the PID with - in front so $0 stop will kill all subprocesses too
echo "-$(cat $DAEMON_PATH/$NAME.pid)" > $DAEMON_PATH/$NAME.pid
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME "
start-stop-daemon --stop $QUIET --pidfile $DAEMON_PATH/$NAME.pid
killall -q phpbitch.php
echo "."
;;
restart|force-reload)
$0 stop
echo ""
sleep 1
$0 start
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0