init script

From: Todd Lyons <tlyons_at_ivenue.com>
Date: Thu, 9 Jun 2011 11:46:57 -0700

Per the recent redhat init script changes, I'm not comfortable with
the init script figuring out where the pid file is supposed to be.
Since this is a RedHat/CentOS system, doing things in the init script
should be done the RedHat way.

Option 1:
On RH, /var/run is the designated place for pid files (postfix being
the one exception, it keeps its pid files in /var/spool/postfix).
Just hardcode it everywhere to /var/run/opendkim/opendkim.pid if
opendkim writes it as a regular user, or /var/run/opendkim.pid if the
init script writes it (because init script running as root can write
there).

Option 2:
In /etc/init.d/functions, there is a pidfileofproc() helper function
which will "do the right thing." Here's how it's used in the sshd
init script:

Global definition:
SSHD=/usr/sbin/sshd

...and then in the stop function:
 stop()
{
        echo -n $"Stopping $prog: "
        if [ -n "`pidfileofproc $SSHD`" ] ; then
            killproc $SSHD
        else
            failure $"Stopping $prog"
        fi
        RETVAL=$?
        # if we are in halt or reboot runlevel kill all running sessions
        # so the TCP connections are closed cleanly
        if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
            killall $prog 2>/dev/null
        fi
        [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/sshd
        echo
}

It should follow something along those lines I would think. This
removes the responsibility of managing the pid file from opendkim and
uses the standard provided helper functions to do its management.

-- 
If Americans could eliminate sugary beverages, potatoes, white bread,
pasta, white rice and sugary snacks, we would wipe out almost all the
problems we have with weight and diabetes and other metabolic
diseases. -- Dr. Walter Willett, Harvard School of Public Health
Received on Thu Jun 09 2011 - 18:47:06 PST

This archive was generated by hypermail 2.3.0 : Mon Oct 29 2012 - 23:33:10 PST