summaryrefslogtreecommitdiff
path: root/security/openssh/files/sshd.sh
blob: e2fd46678eb861ce596c95489d3c9c0467aa0b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# $NetBSD: sshd.sh,v 1.3 2000/07/24 16:44:52 jlam Exp $
#

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