summaryrefslogtreecommitdiff
path: root/contrib/solaris/sshd-initscript.in
blob: 886a51fbaf753b1881e73dba013675ee2467ce62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /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