#!/bin/sh
#
# chkconfig: 345 85 15
# description: SSH Secure Shell daemon
#
# Author: Sami Lehtinen <sjl@ssh.com>
#
# sshd2		This shell script takes care of starting and stopping
#               sshd2.
# 
# partly
#
# Copyright (C) 2000 SSH Communications Security Corp, Helsinki, Finland
#
# Most of the code taken from RedHat Linux /etc/rc.d/init.d/httpd, 
# so I guess
#
# Copyright (C) 1999 RedHat, Inc.

[ -f /usr/local/sbin/sshd2 ] || exit 0

PORT=

PORT=`grep Port /etc/ssh2/sshd2_config | awk '{ x = $2 } END {print x}' -`
if [ "X$PORT" = "X" ]
then
	PORT=22
fi

# See how we were called.

case "$1" in
  start)
	# Start daemons.
	echo -n "Starting sshd2 in port $PORT: "
	/usr/local/sbin/sshd2
	echo "done."
	;;
  stop)
	# Stop daemons.
	echo -n "Shutting down sshd2 in port $PORT: "
	kill `cat /var/run/sshd2_$PORT.pid`
	echo "done."
	;;
  restart)
	$0 stop
	$0 start
	;;
  *)
	echo "Usage: sshd2 {start|stop|restart}"
	exit 1
esac

exit 0
