#!/sbin/sh
#
# NOTE:    This script is not configurable!  Any changes made to this
#          scipt will be overwritten when you upgrade to the next
#          release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
#          is unbootable.  Do not modify this script.
#

#
# Start sshd
#

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

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


case $1 in
start_msg)
	echo "Start ssh daemon"
	;;

stop_msg)
	echo "Stopping primary ssh daemon"
	;;

'start') if [ -f /etc/rc.config.d/sshd ] ; then
	         . /etc/rc.config.d/sshd
	 else
		 echo "ERROR: /etc/rc.config/sshd defaults file MISSING"
	 fi
 

	if (( $START_SSHD )) && [[ -x /opt/ssh/sbin/sshd ]]; then
	    if /opt/ssh/sbin/sshd; then
		echo "Ssh daemon started"
	    else
		set_return
		echo "Could not start ssh daemon"
    	    fi
	else
	    rval=2
	fi
	;;

'stop')
	if [ -f /var/run/sshd.pid ]; then
		kill -TERM `cat /var/run/sshd.pid`
		echo "Ssh primary daemon killed"
	fi
	;;

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

exit $rval
