X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=example%2Fpostlicyd.initd.sh;h=d1e65108aa422aded56b9b842ed1b3e1ce1cec42;hb=1d1c3b7455cc547dc7415edbaf9fd6c2fd0fb2cc;hp=a9f5866a8fa7920226ad730b51ebf2c3151d4fa7;hpb=44dfcc42a03fdd403626e534ab279c9c63593e12;p=apps%2Fpfixtools.git diff --git a/example/postlicyd.initd.sh b/example/postlicyd.initd.sh index a9f5866..d1e6510 100755 --- a/example/postlicyd.initd.sh +++ b/example/postlicyd.initd.sh @@ -9,22 +9,45 @@ POSTLICYD=/usr/sbin/postlicyd PIDFILE=/var/run/postlicyd/pid CONF=/etc/pfixtools/postlicyd.conf -[ -z $1 ] && die "usage $0 (start|stop|reload)" +[ -z $1 ] && die "usage $0 (start|stop|reload|check-conf)" + +mkdir -p `dirname "$PIDFILE"` || die "Can't create $PIDFILE" + +do_checkconf() { + $POSTLICYD -c "$CONF" + return "$?" +} case "$1" in start) - $POSTLICYD -p "$PIDFILE" "$CONF" + echo "Starting postlicyd..." + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $POSTLICYD --text > /dev/null || die "Already running" + do_checkconf || die "Invalid configuration" + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $POSTLICYD -- -p "$PIDFILE" "$CONF" || die "Failed" + echo "Started" ;; stop) - kill `cat $PIDFILE` + echo "Stopping postlicyd..." + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name "postlicyd" + case "$?" in + 0) echo "Stopped" ;; + 1) die "Nothing to stop" ;; + 2) die "Cannot stop process" ;; + esac ;; reload) - kill -HUP `cat $PIDFILE` + echo "Reloading postlicyd..." + do_checkconf || die "Invalid configuration" + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name postlicyd + ;; + + check-conf) + do_checkconf || die "Invalid configuration" ;; *) - die "usage $0 (start|stop|reload)" + die "usage $0 (start|stop|reload|check-conf)" ;; esac