]> git.pld-linux.org Git - packages/openssh.git/blobdiff - opensshd.init
- original from http://www.psc.edu/networking/projects/hpn-ssh/openssh-4.3p1-hpn11...
[packages/openssh.git] / opensshd.init
index 906b27220a498ed44995020db0d6c9237f642334..332adde4c4aef38cec4a482fff68091967a39e69 100644 (file)
@@ -28,6 +28,10 @@ else
        exit 0
 fi
 
+checkconfig() {
+       /usr/sbin/sshd -t || exit 1
+}
+
 RETVAL=0
 # See how we were called.
 case "$1" in
@@ -49,6 +53,8 @@ case "$1" in
                [ -x /sbin/restorecon ] && /sbin/restorecon /etc/ssh/ssh_host_dsa_key || :
        fi
 
+       checkconfig
+
        if [ ! -f /etc/ssh/ssh_host_key ]; then
                msg_not_running OpenSSH
                nls "No SSH host key found! You must run \"%s init\" first." "$0"
@@ -68,13 +74,17 @@ case "$1" in
   stop)
        if [ -f /var/lock/subsys/sshd ]; then
                msg_stopping OpenSSH
-               killproc sshd
-               rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1
+               # we use start-stop-daemon to stop sshd, as it is unacceptable for such
+               # critical service as sshd to kill it by procname, but unfortunately
+               # rc-scripts does not provide way to kill *only* by pidfile
+               start-stop-daemon --stop --quiet --pidfile /var/run/sshd.pid && ok || fail
+               rm -f /var/lock/subsys/sshd >/dev/null 2>&1
        else
                msg_not_running OpenSSH
        fi
        ;;
   restart)
+       checkconfig
        $0 stop
        $0 start
        exit $?
This page took 0.066434 seconds and 4 git commands to generate.