From 9dff7167b71f392ec4706c5e220f52c9e1694d0a Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Sun, 25 Oct 2009 11:00:42 -0400 Subject: [PATCH] conf/redhat/*.init: Use -p option to killproc If a puppetd run was started manually and 'service puppet stop' was run the killproc function used would kill the manually started puppetd. On Fedora and newer RHEL (>= 5) we now use the -p option to prevent this. This fixes #2751 (Red Hat initscripts kill an independently started puppetd/puppetmasterd) Signed-off-by: Todd Zullinger --- conf/redhat/client.init | 7 +++++-- conf/redhat/server.init | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/conf/redhat/client.init b/conf/redhat/client.init index a5ac08d87..0c98383d5 100644 --- a/conf/redhat/client.init +++ b/conf/redhat/client.init @@ -27,6 +27,9 @@ PUPPET_OPTS="" [ -n "$PUPPET_LOG" ] && PUPPET_OPTS="${PUPPET_OPTS} --logdest=${PUPPET_LOG}" [ -n "$PUPPET_PORT" ] && PUPPET_OPTS="${PUPPET_OPTS} --masterport=${PUPPET_PORT}" +# Determine if we can use the -p option to killproc. RHEL < 5 can't. +killproc | grep -q -- '-p' 2>/dev/null && killopts="-p $pidfile" + # Figure out if the system just booted. Let's assume # boot doesn't take longer than 5 minutes ## Not used for now @@ -43,7 +46,7 @@ start() { stop() { echo -n $"Stopping puppet: " - killproc $puppetd + killproc $killopts $puppetd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} @@ -51,7 +54,7 @@ stop() { reload() { echo -n $"Restarting puppet: " - killproc $puppetd -HUP + killproc $killopts $puppetd -HUP RETVAL=$? echo return $RETVAL diff --git a/conf/redhat/server.init b/conf/redhat/server.init index 4bc44b9fb..5505058ed 100644 --- a/conf/redhat/server.init +++ b/conf/redhat/server.init @@ -71,8 +71,9 @@ stop() { ret=$?; [ $ret != 0 ] && RETVAL=$ret done else - killproc $PUPPETMASTER - RETVAL=$? + killproc | grep -q -- '-p' 2>/dev/null && killopts="-p $pidfile" + killproc $killopts $PUPPETMASTER + RETVAL=$? fi echo [ $RETVAL -eq 0 ] && rm -f "$lockfile"