From 2a9ffe26976b9363e757d847f1cfd67025fc4dca Mon Sep 17 00:00:00 2001 From: Michael van Elst Date: Mon, 21 Jul 2003 16:27:10 +0000 Subject: [PATCH] %status and pidfile handling --- postfix-mailgraph/postfix-mailgraph.spec | 2 +- postfix-mailgraph/rc.postfix-mailgraph | 27 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/postfix-mailgraph/postfix-mailgraph.spec b/postfix-mailgraph/postfix-mailgraph.spec index 9f717f111f..b51843ecb1 100644 --- a/postfix-mailgraph/postfix-mailgraph.spec +++ b/postfix-mailgraph/postfix-mailgraph.spec @@ -33,7 +33,7 @@ Distribution: OpenPKG [EVAL] Group: Mail License: GPL Version: 1.4 -Release: 20030719 +Release: 20030721 # list of sources Source0: http://people.ee.ethz.ch/~dws/software/mailgraph/pub/mailgraph-%{version}.tar.gz diff --git a/postfix-mailgraph/rc.postfix-mailgraph b/postfix-mailgraph/rc.postfix-mailgraph index d63d974eba..c00516823a 100644 --- a/postfix-mailgraph/rc.postfix-mailgraph +++ b/postfix-mailgraph/rc.postfix-mailgraph @@ -6,14 +6,33 @@ %config postfix_mailgraph_enable="$openpkg_rc_def" +%common + postfix_mailgraph_pidfile="@l_prefix@/var/postfix-mailgraph/run/mailgraph.pid" + postfix_mailgraph_signal () { + [ -f $postfix_mailgraph_pidfile ] \ + && kill -$1 `cat $postfix_mailgraph_pidfile` + } + +%status -p 200 -u @l_susr@ -o + postfix_mailgraph_usable="unknown" + postfix_mailgraph_active="no" + rcService postfix_mailgraph enable yes && \ + postfix_mailgraph_signal 0 && postfix_mailgraph_active="yes" + echo "postfix_mailgraph_enable=\"$postfix_mailgraph_enable\"" + echo "postfix_mailgraph_usable=\"$postfix_mailgraph_usable\"" + echo "postfix_mailgraph_active=\"$postfix_mailgraph_active\"" + %start -p 100 -u @l_susr@ rcService postfix_mailgraph enable yes || exit 0 @l_prefix@/sbin/mailgraph --daemon %stop -p 200 -u @l_susr@ rcService postfix_mailgraph enable yes || exit 0 - if [ -f @l_prefix@/var/postfix-mailgraph/run/mailgraph.pid ]; then - kill -TERM `cat @l_prefix@/var/postfix-mailgraph/run/mailgraph.pid` >/dev/null 2>&1 || true - sleep 2 - fi + postfix_mailgraph_signal TERM + +%restart -p 200 -u @l_susr@ + rcService postfix_mailgraph enable yes || exit 0 + postfix_mailgraph_signal TERM + sleep 2 + @l_prefix@/sbin/mailgraph --daemon