Ian Kent 66b5fc
autofs-5.0.7 - dont wait forever to restart
Ian Kent 66b5fc
Ian Kent 66b5fc
From: Ian Kent <ikent@redhat.com>
Ian Kent 66b5fc
Ian Kent 66b5fc
When restarting autofs the daemon must be stopped before it is started
Ian Kent 66b5fc
again if it is to function properly. At the moment the init script waits
Ian Kent 66b5fc
forever which is not ok if the daemon won't exit for some reason.
Ian Kent 66b5fc
Ian Kent 66b5fc
So, if the daemon is still running after the stop, run stop() again, wait
Ian Kent 66b5fc
a bit longer and if it still hasn't stopped kill it with a SIGKILL to clear
Ian Kent 66b5fc
the way for the startup.
Ian Kent 66b5fc
---
Ian Kent 66b5fc
Ian Kent 66b5fc
 CHANGELOG             |    1 +
Ian Kent 66b5fc
 redhat/autofs.init.in |   13 ++++++++++---
Ian Kent 66b5fc
 2 files changed, 11 insertions(+), 3 deletions(-)
Ian Kent 66b5fc
Ian Kent 66b5fc
Ian Kent 66b5fc
diff --git a/CHANGELOG b/CHANGELOG
Ian Kent 66b5fc
index 6051723..93b9c26 100644
Ian Kent 66b5fc
--- a/CHANGELOG
Ian Kent 66b5fc
+++ b/CHANGELOG
Ian Kent 66b5fc
@@ -5,6 +5,7 @@
Ian Kent 66b5fc
 - fix ipv6 proximity calculation.
Ian Kent 66b5fc
 - fix parse buffer initialization.
Ian Kent 66b5fc
 - fix typo in automount(8).
Ian Kent 66b5fc
+- dont wait forever to restart.
Ian Kent 66b5fc
 
Ian Kent 66b5fc
 25/07/2012 autofs-5.0.7
Ian Kent 66b5fc
 =======================
Ian Kent 66b5fc
diff --git a/redhat/autofs.init.in b/redhat/autofs.init.in
Ian Kent 66b5fc
index ec6d5d6..cd5cb34 100644
Ian Kent 66b5fc
--- a/redhat/autofs.init.in
Ian Kent 66b5fc
+++ b/redhat/autofs.init.in
Ian Kent 66b5fc
@@ -129,9 +129,16 @@ function restart() {
Ian Kent 66b5fc
 	status autofs > /dev/null 2>&1
Ian Kent 66b5fc
 	if [ $? -eq 0 ]; then
Ian Kent 66b5fc
 		stop
Ian Kent 66b5fc
-		while [ -n "`pidof $prog`" ] ; do
Ian Kent 66b5fc
-			sleep 5
Ian Kent 66b5fc
-		done
Ian Kent 66b5fc
+		if [ -n "`pidof $prog`" ]; then
Ian Kent 66b5fc
+			# If we failed to stop, try at least one more time
Ian Kent 66b5fc
+			# after waiting a little while
Ian Kent 66b5fc
+			sleep 20
Ian Kent 66b5fc
+			stop
Ian Kent 66b5fc
+			auto_pid=`pidof $prog`
Ian Kent 66b5fc
+			if [ -n "$auto_pid" ]; then
Ian Kent 66b5fc
+				kill -9 $auto_pid
Ian Kent 66b5fc
+			fi
Ian Kent 66b5fc
+		fi
Ian Kent 66b5fc
 	fi
Ian Kent 66b5fc
 	start
Ian Kent 66b5fc
 }