From c6b7ad83562006eeb29fb64be21d56bda64ca93c Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 2 Oct 2008 08:35:23 +0200 Subject: [PATCH] Better init.d script. Signed-off-by: Florent Bruneau --- example/postlicyd.initd.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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" ;; *) -- 2.20.1