From: Florent Bruneau Date: Thu, 2 Oct 2008 06:35:23 +0000 (+0200) Subject: Better init.d script. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=c6b7ad83562006eeb29fb64be21d56bda64ca93c;p=apps%2Fpfixtools.git Better init.d script. Signed-off-by: Florent Bruneau --- diff --git a/example/postlicyd.initd.sh b/example/postlicyd.initd.sh index a9f5866..e32764b 100755 --- a/example/postlicyd.initd.sh +++ b/example/postlicyd.initd.sh @@ -13,15 +13,25 @@ CONF=/etc/pfixtools/postlicyd.conf case "$1" in start) - $POSTLICYD -p "$PIDFILE" "$CONF" + mkdir -p `dirname "$PIDFILE"` || die "Can't create $PIDFILE" + echo "Starting postlicyd..." + flock -x -n "$PIDFILE" -c "true" || die "Already started" + $POSTLICYD -p "$PIDFILE" "$CONF" || die "Failed" + echo "Started" ;; stop) - kill `cat $PIDFILE` + echo "Stopping postlicyd..." + ( flock -x -n "$PIDFILE" -c "true" && die "Not started" ) \ + || ( kill `cat $PIDFILE` && echo "Stopped" ) \ + || die "Failed" ;; reload) - kill -HUP `cat $PIDFILE` + echo "Reloading postlicyd..." + ( flock -x -n "$PIDFILE" -c "true" && die "Not started" ) \ + || ( kill -HUP `cat $PIDFILE` && ( sleep 3; echo "Done" ) ) \ + || die "Failed" ;; *)