init script status function doesn't work

From: Todd Lyons <tlyons_at_ivenue.com>
Date: Tue, 12 Oct 2010 14:05:45 -0700

On a CentOS box that has lsb installed, the opendkim init script
detects it and aliases od_killproc and od_daemon to functions provided
by lsb function helper script. The od_status used is the generic
version provided by the opendkim init script.

The design of the od_status needs a bit of help to properly detect the
proper pid of the running process. It makes an assumption that the
pidfile is passed to the function, which it's not. The following
changes work for me and should handle the cases where it's not.

[root_at_mail1 ~]# diff -ruN /etc/init.d/opendkim.orig /etc/init.d/opendkim
--- /etc/init.d/opendkim.orig 2010-10-12 13:43:12.000000000 -0700
+++ /etc/init.d/opendkim 2010-10-12 13:55:15.000000000 -0700
_at_@ -49,15 +49,17 @@
 }

 od_getpid() {
- if [ -n "$1" -a "$1" = "-p" ]; then
+ if [ -n "$1" -a "$1" = "-P" ]; then
                 shift
                 PIDFILE=$1
                 shift
- if [ ! -f "$PIDFILE" ]; then
- return 1
- fi
- PID=$(cat "$PIDFILE")
+ else
+ PIDFILE=$(egrep -i '^pidfile' $CONFIG | head -n 1 | awk '{print $2}')
+ fi
+ if [ ! -f "$PIDFILE" ]; then
+ return 1
         fi
+ PID=$(cat "$PIDFILE")
         if [ -n "$(which pgrep)" ]; then
                 for p in $(pgrep -f $DAEMON); do
                         if [ "$PID" = "$p" ]; then


If egrep is not universal, then grep -E should give the same behavior.

I'm curious if I am the only one who was seeing this behavior, or is
everybody just using the autostart feature now?
-- 
Regards...      Todd
I seek the truth...it is only persistence in self-delusion and
ignorance that does harm.  -- Marcus Aurealius
Received on Tue Oct 12 2010 - 21:05:55 PST

This archive was generated by hypermail 2.3.0 : Mon Oct 29 2012 - 23:32:54 PST