blob: 886a51fbaf753b1881e73dba013675ee2467ce62 [file] [log] [blame]
#! /sbin/sh
# SSHd startup/shutdown script, based on uucp script.
PIDFILE="%%PIDDIR%%/sshd.pid"
PGREP="/usr/bin/pgrep"
HEAD="/usr/bin/head"
XARGS="/usr/bin/xargs"
KILL="/usr/bin/kill"
killproc() {
_procname=$1
_signal=$2
${PGREP} ${_procname} | ${HEAD} -1 | ${XARGS} -t -I {} ${KILL} -${_signal} {}
}
case $1 in
'start')
/usr/local/sbin/sshd
;;
'stop')
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
PID=`cat ${PIDFILE}`
fi
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
/usr/bin/kill $PID
else
echo "Unable to read PID file, killing using alternate method"
killproc sshd TERM
fi
;;
'restart')
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
PID=`cat ${PIDFILE}`
fi
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
/usr/bin/kill -HUP $PID
else
echo "Unable to read PID file, trying alternate method"
killproc sshd HUP
/usr/local/sbin/sshd
fi
;;
*)
echo "usage: /etc/init.d/sshd {start|stop|restart}"
;;
esac