[openssh] Improve init script

Jan F. Chadima jfch2222 at fedoraproject.org
Thu Jun 16 13:45:44 UTC 2011


commit ef264f503b34e1dcc92d014d945e81afe402c1fd
Author: Jan F <jfch at zwingli.jagda.eu>
Date:   Thu Jun 16 15:44:03 2011 +0200

    Improve init script

 openssh.spec |    5 ++++-
 sshd.init    |   26 +++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/openssh.spec b/openssh.spec
index 1d003a5..a3366bd 100644
--- a/openssh.spec
+++ b/openssh.spec
@@ -82,7 +82,7 @@
 
 # Do not forget to bump pam_ssh_agent_auth release if you rewind the main package release to 1
 %define openssh_ver 5.8p2
-%define openssh_rel 7
+%define openssh_rel 8
 %define pam_ssh_agent_ver 0.9.2
 %define pam_ssh_agent_rel 31
 
@@ -750,6 +750,9 @@ exit 0
 %endif
 
 %changelog
+* Thu Jun 16 2011 Jan F. Chadima <jchadima at redhat.com> - 5.8p2-8 + 0.9.2-31
+- Improve init script
+
 * Thu Jun 16 2011 Jan F. Chadima <jchadima at redhat.com> - 5.8p2-7 + 0.9.2-31
 - Add possibility to compile openssh without downstream patches
 
diff --git a/sshd.init b/sshd.init
index 7666070..b08b77f 100755
--- a/sshd.init
+++ b/sshd.init
@@ -142,13 +142,28 @@ start()
 
 stop()
 {
+
 	echo -n $"Stopping $prog: "
-	if [ -n "`pidfileofproc $SSHD`" ] ; then
-	    killproc $SSHD
+	if [ ! -f "$PIDFILE" ]; then
+		# not running; per LSB standards this is "ok"
+		action $"Stopping $prog: " /bin/true
+		return 0
+	fi
+	PID=`cat "$PIDFILE"`
+	if [ -n "$PID" ]; then
+		/bin/kill "$PID" >/dev/null 2>&1
+		RETVAL=$?
+		if [ $RETVAL -eq 0 ]; then
+			RETVAL=1
+			action $"Stopping $prog: " /bin/false
+		else
+			action $"Stopping $prog: " /bin/true
+		fi
 	else
-	    failure $"Stopping $prog"
+		 # failed to read pidfile
+		action $"Stopping $prog: " /bin/false
+		RETVAL=4
 	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
@@ -157,7 +172,8 @@ stop()
 	    trap TERM
 	fi
 	[ $RETVAL -eq 0 ] && rm -f $lockfile
-	echo
+	rm -f "$PIDFILE"
+        return $RETVAL
 }
 
 reload()


More information about the scm-commits mailing list