#!/bin/sh
# script to start/stop sshd
# tested on solaris, irix, a/ux, hp/ux
# peter bartoli <downtime@slagheap.net>
# last modified 1/19/2005

case $1 in
  start_msg)
	echo "starting secure shell daemon"
	;;
  start)
	if [ -x /usr/local/sbin/sshd -a -x /usr/local/bin/ssh-keygen ]; then
	   if [ ! -f /etc/ssh/ssh_host_key ]; then
		/usr/local/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key \
			-N ""
	   fi
	   if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
		/usr/local/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key \
			-N ""
	   fi
	   if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then
		/usr/local/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key \
			-N ""
	   fi
	   echo starting secure shell daemon ...
	   /usr/local/sbin/sshd
	fi
	;;
  stop_msg)
	echo "stopping secure shell daemon"
	;;
  stop)
	echo killing all secure shell daemons ...
	/usr/bin/kill -TERM `/usr/bin/cat /var/run/sshd.pid`
	;;
  restart)
	/usr/bin/kill -HUP `/usr/bin/cat /var/run/sshd.pid`
	;;
  *)
	echo "usage: $0 { start | stop | restart }"
	;;
  esac

# end of script

