#!/sbin/sh

case "$1" in
'start')
	if [ ! -d /etc/ssh ]
	then
		mkdir /etc/ssh
		chmod 700 /etc/ssh
	fi
	if [ ! -f /etc/ssh/ssh_host_key ]
	then
		/usr/local/bin/ssh-keygen -t rsa1 -N "" -C "" -f /etc/ssh/ssh_host_key
	fi
	if [ ! -f /etc/ssh/ssh_host_rsa_key ]
	then
		/usr/local/bin/ssh-keygen -t rsa -N "" -C "" -f /etc/ssh/ssh_host_rsa_key
	fi
	if [ ! -f /etc/ssh/ssh_host_dsa_key ]
	then
		/usr/local/bin/ssh-keygen -t dsa -N "" -C "" -f /etc/ssh/ssh_host_dsa_key
	fi

	if [ -x /usr/local/sbin/sshd ]; then
		/usr/local/sbin/sshd && echo "Started sshd"
	fi
	;;

'stop')
	if [ -f /var/run/sshd.pid ]
	then
		kill `cat /var/run/sshd.pid` && echo "Stopped sshd"
	fi
	;;

*)
	echo "Usage: $0 { start | stop }"
	exit 1
	;;
esac
exit 0

