#!/bin/bash # # /etc/rc.d/init.d/ssh - Start/Stop the ssh daemon(s). # # Source function library. . /etc/rc.d/init.d/functions DAEMON="/usr/local/bin/sshd" get_pid() { echo $1 } case "$1" in start) if [ -f /var/run/sshd.pid ]; then exit 1 fi if [ ! -f $DAEMON ]; then exit 1 fi msg -n "Starting sshd:" daemon --survive=5 $DAEMON if [ "$?" = "0" ]; then ps_line=`ps -ax | grep "$DAEMON" | grep -v grep` pid=`get_pid $ps_line` if [ "$pid" != "" ]; then echo $pid > /var/run/sshd.pid fi fi msg ;; stop) if [ ! -f /var/run/sshd.pid ]; then exit 1 fi if [ ! -f $DAEMON ]; then exit 1 fi msg -n "Stopping sshd:" killproc $DAEMON msg ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 (start|stop|restart)" exit 1 ;; esac exit 0