#!/bin/sh DAEMON=dropbear DAEMON_LONG_NAME="dropbear SSH server" . /etc/init.d/modlibrc pre_config() { [ -d "/tmp/flash/.ssh" ] && mv /tmp/flash/.ssh /tmp/flash/dropbear [ -d /tmp/flash/dropbear ] || mkdir -p /tmp/flash/dropbear [ -e /tmp/flash/rsa_host_key ] && mv /tmp/flash/rsa_host_key /tmp/flash/dropbear/rsa_host_key [ -e /tmp/flash/dss_host_key ] && mv /tmp/flash/dss_host_key /tmp/flash/dropbear/dss_host_key if [ ! -e "/tmp/flash/dropbear/rsa_host_key" -o ! -e "/tmp/flash/dropbear/dss_host_key" ]; then echo "Creating RSA and DSS host keys" rm -f /tmp/flash/dropbear/rsa_host_key rm -f /tmp/flash/dropbear/dss_host_key dropbearkey -t rsa -f /tmp/flash/dropbear/rsa_host_key dropbearkey -t dss -f /tmp/flash/dropbear/dss_host_key /usr/bin/modsave flash fi if [ ! -d "/mod/etc/ssh" ]; then mkdir -p /mod/etc/ssh ln -s /tmp/flash/dropbear/rsa_host_key /mod/etc/ssh/rsa_host_key ln -s /tmp/flash/dropbear/dss_host_key /mod/etc/ssh/dss_host_key fi } start() { if [ "$DROPBEAR_PWDAUTH" = "yes" ]; then if cat /etc/shadow | grep -q '^root:[*!]:'; then echo "Error[$DAEMON]: no root password set - run 'passwd root'" 1>&2 exit 1 fi else DROPBEAR_OPTIONS="-s $DROPBEAR_OPTIONS" fi [ "$DROPBEAR_ROOTONLY" = "yes" ] && DROPBEAR_OPTIONS="-R $DROPBEAR_OPTIONS" set -o noglob modlib_startdaemon $DAEMON -p "$DROPBEAR_PORT" $DROPBEAR_OPTIONS } stop() { killall dropbear 2>/dev/null } case $1 in ""|load) pre_config modreg cgi 'dropbear' 'Dropbear' modreg daemon $DAEMON modlib_start $DROPBEAR_ENABLED ;; unload) modunreg daemon $DAEMON modunreg cgi 'dropbear' modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0