- # Return
- # 0 if daemon has been stopped
- # 1 if daemon was already stopped
- # 2 if daemon could not be stopped
- # other if a failure occurred
- %SENDCOMMAND "DOWN"
-
- #while test -d /proc/`cat $PIDFILE`; do
- # /usr/bin/printf '.'
- # /bin/sleep 1
- #done
- sleep 5
-
- #start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
- #RETVAL="$?"
- #[ "$RETVAL" = 2 ] && return 2
- # Wait for children to finish too if this is a daemon that forks
- # and if the daemon is only ever run from this initscript.
- # If the above conditions are not satisfied then add some other code
- # that waits for the process to drop all resources that could be
- # needed by services started subsequently. A last resort is to
- # sleep for some time.
- #start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
- #[ "$?" = 2 ] && return 2
- # Many daemons don't delete their pidfiles when they exit.
- # rm -f $PIDFILE
+ if test -S $RUNDIR/citadel.socket; then
+ sendcommand "DOWN" || :
+ fi
+
+ PID=`cat $PIDFILE 2>/dev/null || :`
+ if [ ! -z $PID ]; then
+ rm -f $PIDFILE
+ count=0;
+ while test -S /var/run/citadel/citadel.socket -o -d /proc/$PID; do
+ count=$(($count+1))
+ sleep 1
+ echo -n "."
+ if test "$count" = "10"; then
+ kill $PID
+ fi
+ if test "$count" = "20"; then
+ kill -9 $PID
+ rm -rf /var/run/citadel/*
+ fi
+ done
+ return 0
+ fi
+