-config_cb() {
- local cfg="$CONFIG_SECTION"
- local nopasswd
- local type
- config_get cfgtype "$cfg" TYPE
-
- case "$cfgtype" in
- dropbear)
- config_get passauth $cfg PasswordAuth
- config_get port $cfg Port
-
- case "$passauth" in
- no|off|disabled|0) nopasswd=1;;
- esac
- DROPBEAR_ARGS="${port:+-p $port} ${nopasswd:+-s}"
- ;;
- esac
+NAME=dropbear
+PROG=/usr/sbin/dropbear
+START=50
+STOP=50
+PIDCOUNT=0
+EXTRA_COMMANDS="killclients"
+EXTRA_HELP=" killclients Kill ${NAME} processes except servers and yourself"
+
+dropbear_start()
+{
+ local section="$1"
+
+ # check if section is enabled (default)
+ local enabled
+ config_get_bool enabled "${section}" enable 1
+ [ "${enabled}" -eq 0 ] && return 1
+
+ # verbose parameter
+ local verbosed
+ config_get_bool verbosed "${section}" verbose 0
+
+ # increase pid file count to handle multiple instances correctly
+ PIDCOUNT="$(( ${PIDCOUNT} + 1))"
+
+ # prepare parameters (initialise with pid file)
+ local args="-P /var/run/${NAME}.${PIDCOUNT}.pid"
+ local val
+ # A) password authentication
+ config_get_bool val "${section}" PasswordAuth 1
+ [ "${val}" -eq 0 ] && append args "-s"
+ # B) listen interface and port
+ local interface
+ local address
+ config_get interface "${section}" Interface
+ config_get address "${interface}" ipaddr
+ config_get val "${section}" Port
+ val="${address:+${address}:}${val}"
+ [ -n "${val}" ] && append args "-p ${val}"
+ # C) banner file
+ config_get val "${section}" BannerFile
+ [ -f "${val}" ] && append args "-b ${val}"
+ # D) gatewayports
+ config_get_bool val "${section}" GatewayPorts 0
+ [ "${val}" -eq 1 ] && append args "-a"
+ # E) root password authentication
+ config_get_bool val "${section}" RootPasswordAuth 1
+ [ "${val}" -eq 0 ] && append args "-g"
+ # F) root login
+ config_get_bool val "${section}" RootLogin 1
+ [ "${val}" -eq 0 ] && append args "-w"
+ # G) host keys
+ config_get val "${section}" rsakeyfile
+ [ -f "${val}" ] && append args "-r ${val}"
+ config_get val "${section}" dsskeyfile
+ [ -f "${val}" ] && append args "-d ${val}"
+
+ # execute program and return its exit code
+ [ "${verbosed}" -ne 0 ] && echo "${initscript}: section ${section} starting ${PROG} ${args}"
+ ${PROG} ${args}
+ return $?