83eb2c3700
literal name_enable wherever possible, and ${name}_enable when it's not, to prepare for the demise of set_rcvar(). In cases where I had to hand-edit unusual instances also modify formatting slightly to be more uniform (and in some cases, correct). This includes adding some $FreeBSD$ tags, and most importantly moving rcvar= to right after name= so it's clear that one is derived from the other.
62 lines
1.3 KiB
Bash
62 lines
1.3 KiB
Bash
#!/bin/sh
|
|
|
|
# PROVIDE: dropbear
|
|
# REQUIRE: LOGIN cleanvar
|
|
#
|
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
|
# to enable this service:
|
|
#
|
|
# dropbear_enable (bool): Set to NO by default.
|
|
# Set it to YES to enable dropbear.
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="dropbear"
|
|
rcvar=dropbear_enable
|
|
command="%%PREFIX%%/sbin/${name}"
|
|
keygen_cmd="dropbear_keygen"
|
|
start_precmd="dropbear_precmd"
|
|
pidfile="/var/run/${name}.pid"
|
|
extra_commands="keygen"
|
|
|
|
etcdir="%%PREFIX%%/etc/${name}"
|
|
|
|
dropbear_keygen()
|
|
{
|
|
(
|
|
umask 022
|
|
|
|
if [ -f ${etcdir}/dropbear_rsa_host_key ]; then
|
|
echo "You already have an RSA host key" \
|
|
"in ${etcdir}/dropbear_rsa_host_key"
|
|
echo "Skipping protocol version 2 RSA Key Generation"
|
|
else
|
|
%%PREFIX%%/bin/dropbearkey -t rsa -f ${etcdir}/dropbear_rsa_host_key
|
|
fi
|
|
|
|
if [ -f ${etcdir}/dropbear_dss_host_key ]; then
|
|
echo "You already have an DSS host key" \
|
|
"in ${etcdir}/dropbear_dss_host_key"
|
|
echo "Skipping protocol version 2 DSS Key Generation"
|
|
else
|
|
%%PREFIX%%/bin/dropbearkey -t dss -f ${etcdir}/dropbear_dss_host_key
|
|
fi
|
|
)
|
|
}
|
|
|
|
dropbear_precmd()
|
|
{
|
|
if [ ! -f ${etcdir}/dropbear_rsa_host_key -o \
|
|
! -f ${etcdir}/dropbear_dss_host_key ]; then
|
|
run_rc_command keygen
|
|
fi
|
|
}
|
|
|
|
load_rc_config $name
|
|
|
|
: ${dropbear_enable="NO"}
|
|
|
|
command_args="-P $pidfile"
|
|
|
|
run_rc_command "$1"
|