#! /bin/sh # $Id$ # $URL$ ### BEGIN INIT INFO # Provides: harvester # Required-Start: $syslog $named $network $time # Required-Stop: $syslog $named $network $time # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start harvester daemon # Description: Beter Zoeken & Vinden server ### END INIT INFO export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=harvester DESC='Harvester daemon' DAEMON=/usr/bin/startharvester.sh CONFDIR=/etc/harvester BINSH=/bin/sh USER=harvest export LANG=en_US.UTF-8 # Include harvester defaults if available if [ -f /etc/default/harvester ] then . /etc/default/harvester fi test -x $DAEMON || exit 0 start() { start-stop-daemon --start --quiet --pidfile "/var/run/$1.pid" --user ${USER%:*} --chuid $USER --background --make-pidfile --exec $BINSH -- $DAEMON "$CONFDIR/$1.cf" } stop() { start-stop-daemon --stop --quiet --pidfile "/var/run/$1.pid" --user ${USER%:*} --exec $BINSH } isrunning() { start-stop-daemon --stop --test --quiet --pidfile "/var/run/$1.pid" --user ${USER%:*} --exec $BINSH >/dev/null } instances() { for cf in $CONFDIR/*.cf do name=${cf##*/} name=${name%.cf} echo $name done } case $1 in start) echo -n "Starting $DESC:" for i in $(instances) do echo -n " $i" start "$i" done echo . ;; stop) echo -n "Stopping $DESC:" for i in $(instances) do echo -n " $i" stop "$i" done echo . ;; force-reload) # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart" except that it does nothing if the # daemon isn't already running. # check wether $DAEMON is running. If so, restart echo -n "Force-reloading $DESC:" for i in $(instances) do if isrunning "$i" then echo -n " $i" stop "$i" sleep 1 start "$i" else echo -n " ($i)" fi done echo . ;; restart) echo -n "Restarting $DESC:" for i in $(instances) do echo -n " $i" if isrunning "$i" then stop "$i" sleep 1 else echo -n '(!)' fi start "$i" done echo . ;; status) for i in $(instances) do isrunning "$i" || exit 1 done exit 0 ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0