diff options
author | Tim Rice <tim@multitalents.net> | 2004-06-20 04:31:06 +0200 |
---|---|---|
committer | Tim Rice <tim@multitalents.net> | 2004-06-20 04:31:06 +0200 |
commit | 5af9db9e0c7dce664d4bea2fc776fc9f4631aeaa (patch) | |
tree | e6781d73b2194cb6e7aade8e8ddb8940c791288b /opensshd.init.in | |
parent | - (dtucker) [auth-pam.c] Don't use PAM namespace for (diff) | |
download | openssh-5af9db9e0c7dce664d4bea2fc776fc9f4631aeaa.tar.xz openssh-5af9db9e0c7dce664d4bea2fc776fc9f4631aeaa.zip |
- (tim) [configure.ac buildpkg.sh.in contrib/solaris/README] move opensshd
init script to top level directory.
Diffstat (limited to 'opensshd.init.in')
-rwxr-xr-x | opensshd.init.in | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/opensshd.init.in b/opensshd.init.in new file mode 100755 index 000000000..ffa7cdac2 --- /dev/null +++ b/opensshd.init.in @@ -0,0 +1,82 @@ +#!/sbin/sh +# Donated code that was put under PD license. +# +# Stripped PRNGd out of it for the time being. + +umask 022 + +CAT=@CAT@ +KILL=@KILL@ + +prefix=@prefix@ +sysconfdir=@sysconfdir@ +piddir=@piddir@ + +SSHD=$prefix/sbin/sshd +PIDFILE=$piddir/sshd.pid +SSH_KEYGEN=$prefix/bin/ssh-keygen +HOST_KEY_RSA1=$sysconfdir/ssh_host_key +HOST_KEY_DSA=$sysconfdir/ssh_host_dsa_key +HOST_KEY_RSA=$sysconfdir/ssh_host_rsa_key + + +checkkeys() { + if [ ! -f $HOST_KEY_RSA1 ]; then + ${SSH_KEYGEN} -t rsa1 -f ${HOST_KEY_RSA1} -N "" + fi + if [ ! -f $HOST_KEY_DSA ]; then + ${SSH_KEYGEN} -t dsa -f ${HOST_KEY_DSA} -N "" + fi + if [ ! -f $HOST_KEY_RSA ]; then + ${SSH_KEYGEN} -t rsa -f ${HOST_KEY_RSA} -N "" + fi +} + +stop_service() { + if [ -r $PIDFILE -a ! -z ${PIDFILE} ]; then + PID=`${CAT} ${PIDFILE}` + fi + if [ ${PID:=0} -gt 1 -a ! "X$PID" = "X " ]; then + ${KILL} ${PID} + else + echo "Unable to read PID file" + 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 + echo "$0: Error ${sshd_rc} starting ${SSHD}... bailing." + exit $sshd_rc + 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 |