#!/bin/bash # # /etc/rc.d/init.d/newpki # # Starts the NewPKI daemon # # chkconfig: - 98 18 # description: Starts the NewPKI daemon # processname: newpki # Source function library. . /etc/rc.d/init.d/functions prog="NewPKI" NEWPKI_CONF=/etc/newpki/config.conf NEWPKI_USER=newpki PIDFILE=/var/run/newpki.pid pkistart(){ echo -n "Starting $prog: " if test -f /var/lock/subsys/newpki; then echo_failure echo "" return 1 fi newpki-server -config $NEWPKI_CONF -user $NEWPKI_USER -detach -pidfile $PIDFILE ret=$? if [ $ret -eq 0 ]; then echo_success touch /var/lock/subsys/newpki else echo_failure fi echo "" return $ret } pkistop(){ echo -n "Stopping $prog: " rm -f /var/lock/subsys/newpki 2>/dev/null >&2 if [ -f $PIDFILE ]; then kill `cat $PIDFILE` 2>/dev/null >&2 if [ $? -eq 0 ]; then echo_success else echo_failure fi echo rm -f $PIDFILE 2>/dev/null >&2 return 0 else echo_failure echo return 1 fi } pkirestart(){ pkistop sleep 10 pkistart } # See how we were called. case "$1" in start) pkistart ;; stop) pkistop ;; restart) pkirestart ;; status) status newpki-server exit $? ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit $?