Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / security / openssh / files / sshd.sh
blob49d523a382919274cd165b851e6e9ba475ba84d5
1 #!@RCD_SCRIPTS_SHELL@
3 # $NetBSD: sshd.sh,v 1.12 2011/05/16 05:06:49 taca Exp $
5 # PROVIDE: sshd
6 # REQUIRE: DAEMON LOGIN
8 if [ -f /etc/rc.subr ]
9 then
10 . /etc/rc.subr
13 name="sshd"
14 rcvar=$name
15 command="@PREFIX@/sbin/${name}"
16 keygen_command="@PREFIX@/bin/ssh-keygen"
17 pidfile="@SSH_PID_DIR@/${name}.pid"
18 required_files="@PKG_SYSCONFDIR@/sshd_config"
19 extra_commands="keygen reload"
21 sshd_keygen()
24 umask 022
25 if [ -f @PKG_SYSCONFDIR@/ssh_host_key ]; then
26 @ECHO@ "You already have an RSA host key in @PKG_SYSCONFDIR@/ssh_host_key"
27 @ECHO@ "Skipping protocol version 1 RSA Key Generation"
28 else
29 ${keygen_command} -t rsa1 -b 1024 -f @PKG_SYSCONFDIR@/ssh_host_key -N ''
32 if [ -f @PKG_SYSCONFDIR@/ssh_host_dsa_key ]; then
33 @ECHO@ "You already have a DSA host key in @PKG_SYSCONFDIR@/ssh_host_dsa_key"
34 @ECHO@ "Skipping protocol version 2 DSA Key Generation"
35 else
36 ${keygen_command} -t dsa -f @PKG_SYSCONFDIR@/ssh_host_dsa_key -N ''
39 if [ -f @PKG_SYSCONFDIR@/ssh_host_rsa_key ]; then
40 @ECHO@ "You already have a RSA host key in @PKG_SYSCONFDIR@/ssh_host_rsa_key"
41 @ECHO@ "Skipping protocol version 2 RSA Key Generation"
42 else
43 ${keygen_command} -t rsa -f @PKG_SYSCONFDIR@/ssh_host_rsa_key -N ''
45 /* HAVE_ECDSA_START */
46 if [ -f @PKG_SYSCONFDIR@/ssh_host_ecdsa_key ]; then
47 @ECHO@ "You already have a ECDSA host key in @PKG_SYSCONFDIR@/ssh_host_ecdsa_key"
48 @ECHO@ "Skipping protocol version 2 ECDSA Key Generation"
49 else
50 ${keygen_command} -t ecdsa -f @PKG_SYSCONFDIR@/ssh_host_ecdsa_key -N ''
52 /* HAVE_ECDSA_STOP */
56 sshd_precmd()
58 if [ ! -f @PKG_SYSCONFDIR@/ssh_host_key -o \
59 ! -f @PKG_SYSCONFDIR@/ssh_host_dsa_key -o \
60 ! -f @PKG_SYSCONFDIR@/ssh_host_rsa_key -o \
61 ! -f @PKG_SYSCONFDIR@/ssh_host_ecdsa_key ]; then
62 if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]
63 then
64 run_rc_command keygen
65 else
66 eval ${keygen_cmd}
71 keygen_cmd=sshd_keygen
72 start_precmd=sshd_precmd
74 if [ -f /etc/rc.subr -a -f /etc/rc.conf -a -f /etc/rc.d/DAEMON ]
75 then
76 load_rc_config $name
77 run_rc_command "$1"
78 else
79 case ${1:-start} in
80 start)
81 if [ -x ${command} -a -f ${required_files} ]
82 then
83 @ECHO@ "Starting ${name}."
84 eval ${start_precmd}
85 eval ${command} ${sshd_flags} ${command_args}
88 stop)
89 if [ -f ${pidfile} ]; then
90 pid=`@HEAD@ -1 ${pidfile}`
91 @ECHO@ "Stopping ${name}."
92 kill -TERM ${pid}
93 else
94 @ECHO@ "${name} not running?"
97 restart)
98 ( $0 stop )
99 sleep 1
100 $0 start
102 status)
103 if [ -f ${pidfile} ]; then
104 pid=`@HEAD@ -1 ${pidfile}`
105 @ECHO@ "${name} is running as pid ${pid}."
106 else
107 @ECHO@ "${name} is not running."
110 keygen)
111 eval ${keygen_cmd}
113 esac