xref: /freebsd/crypto/openssh/contrib/hpux/sshd.rc (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1#!/sbin/sh
2
3#
4# sshd.rc: SSH daemon start-up and shutdown script
5#
6
7# Allowed exit values:
8#	0 = success; causes "OK" to show up in checklist.
9#	1 = failure; causes "FAIL" to show up in checklist.
10#	2 = skip; causes "N/A" to show up in the checklist.
11#           Use this value if execution of this script is overridden
12#	    by the use of a control variable, or if this script is not
13#	    appropriate to execute for some other reason.
14#       3 = reboot; causes the system to be rebooted after execution.
15
16# Input and output:
17#	stdin is redirected from /dev/null
18#
19#	stdout and stderr are redirected to the /etc/rc.log file
20#	during checklist mode, or to the console in raw mode.
21
22PATH=/usr/sbin:/usr/bin:/sbin
23export PATH
24
25WHAT='OpenSSH'
26WHAT_PATH=/opt/openssh/sbin/sshd
27WHAT_PID=/var/run/sshd.pid
28WHAT_CONFIG=/etc/rc.config.d/sshd
29
30# NOTE: If your script executes in run state 0 or state 1, then /usr might
31#	not be available.  Do not attempt to access commands or files in
32#	/usr unless your script executes in run state 2 or greater.  Other
33#	file systems typically not mounted until run state 2 include /var
34#	and /opt.
35
36rval=0
37
38# Check the exit value of a command run by this script.  If non-zero, the
39# exit code is echoed to the log file and the return value of this script
40# is set to indicate failure.
41
42set_return() {
43	x=$?
44	if [ $x -ne 0 ]; then
45		echo "EXIT CODE: $x"
46		rval=1	# script FAILed
47	fi
48}
49
50case $1 in
51'start_msg')
52	echo "Starting $WHAT"
53	;;
54
55'stop_msg')
56	echo "Stopping $WHAT"
57	;;
58
59'start')
60	if [ -f $WHAT_CONFIG ] ; then
61		. $WHAT_CONFIG
62	else
63		echo "ERROR: $WHAT_CONFIG defaults file MISSING"
64	fi
65
66	if [ "$SSHD_START" -eq 1 -a -x "$WHAT_PATH" ]; then
67		$WHAT_PATH $SSHD_ARGS && echo "$WHAT started"
68		set_return
69	else
70		rval=2
71	fi
72	;;
73
74'stop')
75	if kill `cat $WHAT_PID`; then
76		echo "$WHAT stopped"
77	else
78		rval=1
79		echo "Unable to stop $WHAT"
80	fi
81	set_return
82	;;
83
84*)
85	echo "usage: $0 {start|stop|start_msg|stop_msg}"
86	rval=1
87	;;
88esac
89
90exit $rval
91