2006-01-29 14:22:39 +01:00
|
|
|
#!@STARTUP_SCRIPT_SHELL@
|
2001-10-12 22:30:52 +02:00
|
|
|
# Donated code that was put under PD license.
|
|
|
|
#
|
|
|
|
# Stripped PRNGd out of it for the time being.
|
|
|
|
|
2002-11-14 00:50:04 +01:00
|
|
|
umask 022
|
|
|
|
|
2004-06-20 04:31:06 +02:00
|
|
|
CAT=@CAT@
|
|
|
|
KILL=@KILL@
|
2001-10-12 22:30:52 +02:00
|
|
|
|
2004-06-20 04:31:06 +02:00
|
|
|
prefix=@prefix@
|
|
|
|
sysconfdir=@sysconfdir@
|
|
|
|
piddir=@piddir@
|
2001-10-12 22:30:52 +02:00
|
|
|
|
2001-10-12 23:52:39 +02:00
|
|
|
SSHD=$prefix/sbin/sshd
|
2001-10-19 22:36:23 +02:00
|
|
|
PIDFILE=$piddir/sshd.pid
|
2009-11-21 04:32:15 +01:00
|
|
|
PidFile=`grep "^PidFile" ${sysconfdir}/sshd_config | tr "=" " " | awk '{print $2}'`
|
|
|
|
[ X$PidFile = X ] || PIDFILE=$PidFile
|
2001-10-12 23:52:39 +02:00
|
|
|
SSH_KEYGEN=$prefix/bin/ssh-keygen
|
2004-06-20 04:31:06 +02:00
|
|
|
HOST_KEY_RSA1=$sysconfdir/ssh_host_key
|
|
|
|
HOST_KEY_DSA=$sysconfdir/ssh_host_dsa_key
|
|
|
|
HOST_KEY_RSA=$sysconfdir/ssh_host_rsa_key
|
2001-10-12 22:30:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
checkkeys() {
|
|
|
|
if [ ! -f $HOST_KEY_RSA1 ]; then
|
2003-11-21 13:48:55 +01:00
|
|
|
${SSH_KEYGEN} -t rsa1 -f ${HOST_KEY_RSA1} -N ""
|
2001-10-12 22:30:52 +02:00
|
|
|
fi
|
|
|
|
if [ ! -f $HOST_KEY_DSA ]; then
|
2003-11-21 13:48:55 +01:00
|
|
|
${SSH_KEYGEN} -t dsa -f ${HOST_KEY_DSA} -N ""
|
2001-10-12 22:30:52 +02:00
|
|
|
fi
|
|
|
|
if [ ! -f $HOST_KEY_RSA ]; then
|
2003-11-21 13:48:55 +01:00
|
|
|
${SSH_KEYGEN} -t rsa -f ${HOST_KEY_RSA} -N ""
|
2001-10-12 22:30:52 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_service() {
|
|
|
|
if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then
|
2003-11-21 13:48:55 +01:00
|
|
|
PID=`${CAT} ${PIDFILE}`
|
2001-10-12 22:30:52 +02:00
|
|
|
fi
|
|
|
|
if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then
|
2003-11-21 13:48:55 +01:00
|
|
|
${KILL} ${PID}
|
2001-10-12 22:30:52 +02:00
|
|
|
else
|
2003-11-21 13:48:55 +01:00
|
|
|
echo "Unable to read PID file"
|
2001-10-12 22:30:52 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
start_service() {
|
|
|
|
# XXX We really should check if the service is already going, but
|
|
|
|
# XXX we will opt out at this time. - Bal
|
|
|
|
|
|
|
|
# Check to see if we have keys that need to be made
|
|
|
|
checkkeys
|
|
|
|
|
|
|
|
# Start SSHD
|
|
|
|
echo "starting $SSHD... \c" ; $SSHD
|
|
|
|
|
|
|
|
sshd_rc=$?
|
|
|
|
if [ $sshd_rc -ne 0 ]; then
|
2003-11-21 13:48:55 +01:00
|
|
|
echo "$0: Error ${sshd_rc} starting ${SSHD}... bailing."
|
|
|
|
exit $sshd_rc
|
2001-10-12 22:30:52 +02:00
|
|
|
fi
|
|
|
|
echo done.
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
|
|
|
|
'start')
|
|
|
|
start_service
|
|
|
|
;;
|
|
|
|
|
|
|
|
'stop')
|
|
|
|
stop_service
|
|
|
|
;;
|
|
|
|
|
|
|
|
'restart')
|
|
|
|
stop_service
|
|
|
|
start_service
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "$0: usage: $0 {start|stop|restart}"
|
|
|
|
;;
|
|
|
|
esac
|