From ef264f503b34e1dcc92d014d945e81afe402c1fd Mon Sep 17 00:00:00 2001 From: Jan F Date: Thu, 16 Jun 2011 15:44:03 +0200 Subject: [PATCH] Improve init script --- openssh.spec | 5 ++++- sshd.init | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 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 - 5.8p2-8 + 0.9.2-31 +- Improve init script + * Thu Jun 16 2011 Jan F. Chadima - 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 - else - failure $"Stopping $prog" + 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 + # 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()