From 4edda79a7c169e45dfb680d5a7a6d1e4958c06db Mon Sep 17 00:00:00 2001 From: jlam Date: Mon, 24 Jul 2000 16:44:52 +0000 Subject: Make all the installed /usr/pkg/etc/rc.d/sshd.sh files match. Also default to "start" command if run with no arguments. --- security/ssh/files/sshd.sh | 56 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 10 deletions(-) (limited to 'security/ssh') diff --git a/security/ssh/files/sshd.sh b/security/ssh/files/sshd.sh index 7f89964346e..da23c72b8bd 100644 --- a/security/ssh/files/sshd.sh +++ b/security/ssh/files/sshd.sh @@ -1,14 +1,50 @@ #!/bin/sh # -# $NetBSD: sshd.sh,v 1.2 1999/06/20 19:47:31 kim Exp $ +# $NetBSD: sshd.sh,v 1.3 2000/07/24 16:44:53 jlam Exp $ # -if [ ! -f @SSH_CONF_DIR@/ssh_host_key ] -then - @PREFIX@/bin/ssh-keygen -f @SSH_CONF_DIR@/ssh_host_key -N '' -fi -if [ -x @PREFIX@/sbin/sshd -a -f @SSH_CONF_DIR@/sshd_config ] -then - @PREFIX@/sbin/sshd - echo -n ' sshd' -fi + +name="sshd" +pidfile="/var/run/${name}.pid" + +command=${1:-start} + +case ${command} in +start) + if [ ! -f @SSH_CONF_DIR@/ssh_host_key ] + then + @PREFIX@/bin/ssh-keygen -b 1024 -N "" -f /etc/ssh_host_key + fi + if [ ! -f @SSH_CONF_DIR@/ssh_host_dsa_key ] + then + /usr/pkg/bin/ssh-keygen -d -N "" -f /etc/ssh_host_dsa_key + fi + if [ -x @PREFIX@/sbin/sshd -a -f @SSH_CONF_DIR@/sshd_config ] + then + echo "Starting ${name}." + @PREFIX@/sbin/sshd + fi + ;; +stop) + if [ -f ${pidfile} ]; then + pid=`head -1 ${pidfile}` + echo "Stopping ${name}." + kill -TERM ${pid} + else + echo "${name} not running?" + fi + ;; +restart) + ( $0 stop ) + sleep 1 + $0 start + ;; +status) + if [ -f ${pidfile} ]; then + pid=`head -1 ${pidfile}` + echo "${name} is running as pid ${pid}." + else + echo "${name} is not running." + fi + ;; +esac exit 0 -- cgit v1.2.3