summaryrefslogtreecommitdiff
path: root/contrib/hpux/sshd.rc
blob: f9a10999b01c528cbc444c63f658f99961563256 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/sbin/sh

#
# sshd.rc: SSH daemon start-up and shutdown script
#

# Allowed exit values:
#	0 = success; causes "OK" to show up in checklist.
#	1 = failure; causes "FAIL" to show up in checklist.
#	2 = skip; causes "N/A" to show up in the checklist.
#           Use this value if execution of this script is overridden
#	    by the use of a control variable, or if this script is not
#	    appropriate to execute for some other reason.
#       3 = reboot; causes the system to be rebooted after execution.

# Input and output:
#	stdin is redirected from /dev/null
#
#	stdout and stderr are redirected to the /etc/rc.log file
#	during checklist mode, or to the console in raw mode.

PATH=/usr/sbin:/usr/bin:/sbin
export PATH

WHAT='OpenSSH'
WHAT_PATH=/opt/openssh/sbin/sshd
WHAT_PID=/var/run/sshd.pid
WHAT_CONFIG=/etc/rc.config.d/sshd

# NOTE: If your script executes in run state 0 or state 1, then /usr might
#	not be available.  Do not attempt to access commands or files in
#	/usr unless your script executes in run state 2 or greater.  Other
#	file systems typically not mounted until run state 2 include /var
#	and /opt.

rval=0

# Check the exit value of a command run by this script.  If non-zero, the
# exit code is echoed to the log file and the return value of this script
# is set to indicate failure.

set_return() {
	x=$?
	if [ $x -ne 0 ]; then
		echo "EXIT CODE: $x"
		rval=1	# script FAILed
	fi
}

case $1 in
'start_msg')
	echo "Starting $WHAT"
	;;

'stop_msg')
	echo "Stopping $WHAT"
	;;

'start')
	if [ -f $WHAT_CONFIG ] ; then
		. $WHAT_CONFIG
	else
		echo "ERROR: $WHAT_CONFIG defaults file MISSING"
	fi
	
	if [ "$SSHD_START" -eq 1 -a -x "$WHAT_PATH" ]; then
		$WHAT_PATH $SSHD_ARGS && echo "$WHAT started"
		set_return
	else
		rval=2
	fi
	;;

'stop')
	if kill `cat $WHAT_PID`; then
		echo "$WHAT stopped"
	else
		rval=1
		echo "Unable to stop $WHAT"
	fi
	set_return
	;;

*)
	echo "usage: $0 {start|stop|start_msg|stop_msg}"
	rval=1
	;;
esac

exit $rval