#!/bin/sh
#
# Start/Stop the secure shell daemon.
#
# Written by Michael Haardt, 1996.
#
#From: michael@cantor.informatik.rwth-aachen.de (Michael Haardt)
#...
#I appended a shell script to this email, which starts/stops sshd in SYSV
#like style.  If you are interested, you can include it in the
#distribution.  It goes to /etc/init.d/sshd and has symlinks from the
#/etc/rc?.d directories to it, but the details of those links differ
#among systems.  SYSV admins will know what to do with the script,
#though.  :)
#
# Sean for solaris 2.4:
# cp startup-script /etc/init.d/sshd
# ln -s /etc/init.d/sshd /etc/rc2.d/S10sshd
# ln -s /etc/init.d/sshd /etc/rc2.d/K10sshd

PATH=/bin:/usr/bin
SSHD=/usr/sbin/sshd
PID=/var/run/sshd.pid

case $1 in
  #{{{script}}}#{{{ start
  'start')
    start=false
    if [ ! -s $PID ]
    then
      start=true
    else
      kill -0 `cat $PID` >/dev/null 2>&1 || start=true
    fi
    if [ $start = true -a -x $SSHD ]
    then
      $SSHD
      echo 'Secure shell daemon started.'
    else
      echo 'Secure shell daemon not started.'
    fi
  ;;
  #}}}
  #{{{ stop
  'stop')
    if [ -s $PID ]
    then
      if kill `cat $PID` >/dev/null 2>&1
      then
        echo 'Secure shell daemon terminated.'
      fi
    fi
  ;;
  #}}}
  #{{{ *
  *)
    echo 'Usage: /etc/init.d/sshd start|stop'
    ;;
  #}}}
esac

