#!/bin/sh -e # ### BEGIN INIT INFO # Provides: sks # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO # # Start/stops the sks daemons. # # # Reads config file [ -r /etc/default/sks ] && . /etc/default/sks DAEMON=/usr/sbin/sks SKSDBPID=/var/run/sks/sksdb.pid SKSRECONPID=/var/run/sks/sksrecon.pid # See if the daemon is there test -e $DAEMON || exit 0 if [ ! -x $DAEMON ]; then echo "ERROR: $DAEMON is not executable" exit 1 fi . /lib/lsb/init-functions wait_for_deaddaemon () { pidfile=$1 pid=`cat $pidfile 2>/dev/null` || true sleep 1 if test -n "$pid" then if kill -0 $pid 2>/dev/null then echo -n "." cnt=0 while kill -0 $pid 2>/dev/null do cnt=`expr $cnt + 1` if [ $cnt -gt 30 ] then echo " FAILED." return 1 fi sleep 2 echo -n "." done rm -f $pidfile else rm -f $pidfile fi fi return 0 } case "$1" in start) echo -n "Starting sks daemons:" if [ "$initstart" != "yes" ]; then echo " Not starting sks (as configured in /etc/default/sks)" exit 0 fi mkdir -p `dirname "$SKSDBPID"` chown debian-sks `dirname "$SKSDBPID"` echo -n " sksdb.." start-stop-daemon --start --quiet --oknodo \ --chuid debian-sks:debian-sks \ --make-pidfile \ --pidfile $SKSDBPID \ --exec $DAEMON -- db & echo -n " sksrecon.." start-stop-daemon --start --quiet --oknodo \ --chuid debian-sks:debian-sks \ --make-pidfile \ --pidfile $SKSRECONPID \ --exec $DAEMON -- recon & echo " done." ;; stop) echo -n "Stopping sks daemons:" echo -n " sksrecon.." start-stop-daemon --stop --quiet --oknodo --pidfile $SKSRECONPID wait_for_deaddaemon $SKSRECONPID || exit 1 echo -n " sksdb.." start-stop-daemon --stop --quiet --oknodo --pidfile $SKSDBPID wait_for_deaddaemon $SKSDBPID || exit 1 echo " done." ;; reload) # Hupping at least reopens logfiles. # membership and mailsync are regularily read anyway # not sure about the rest # -- weasel echo -n "Reloading sks daemons:" echo -n " sksrecon.." start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $SKSRECONPID echo -n " sksdb.." start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $SKSDBPID echo " done." ;; restart|force-reload) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|reload|restart|force-reload}" exit 1 ;; esac exit 0