1#!/bin/sh 2# 3# Do not configure this file. Edit /etc/default/dropbear instead! 4# 5 6PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 7DAEMON=/usr/sbin/dropbear 8NAME=dropbear 9DESC="Dropbear SSH server" 10 11DROPBEAR_PORT=22 12DROPBEAR_EXTRA_ARGS= 13NO_START=0 14 15set -e 16 17cancel() { echo "$1" >&2; exit 0; }; 18test ! -r /etc/default/dropbear || . /etc/default/dropbear 19test -x "$DAEMON" || cancel "$DAEMON does not exist or is not executable." 20test ! -h /var/service/dropbear || \ 21 cancel '/var/service/dropbear exists, service is controlled through runit.' 22 23test -z "$DROPBEAR_BANNER" || \ 24 DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER" 25test -n "$DROPBEAR_RSAKEY" || \ 26 DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key" 27test -n "$DROPBEAR_DSSKEY" || \ 28 DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key" 29 30case "$1" in 31 start) 32 test "$NO_START" = "0" || cancel 'NO_START is not set to zero.' 33 echo -n "Starting $DESC: " 34 start-stop-daemon --start --quiet --pidfile /var/run/"$NAME".pid \ 35 --exec "$DAEMON" -- -d "$DROPBEAR_DSSKEY" -r "$DROPBEAR_RSAKEY" \ 36 -p "$DROPBEAR_PORT" $DROPBEAR_EXTRA_ARGS 37 echo "$NAME." 38 ;; 39 stop) 40 echo -n "Stopping $DESC: " 41 start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/"$NAME".pid 42 echo "$NAME." 43 ;; 44 restart|force-reload) 45 test "$NO_START" = "0" || cancel 'NO_START is not set to zero.' 46 echo -n "Restarting $DESC: " 47 start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/"$NAME".pid 48 sleep 1 49 start-stop-daemon --start --quiet --pidfile /var/run/"$NAME".pid \ 50 --exec "$DAEMON" -- -d "$DROPBEAR_DSSKEY" -r "$DROPBEAR_RSAKEY" \ 51 -p "$DROPBEAR_PORT" $DROPBEAR_EXTRA_ARGS 52 echo "$NAME." 53 ;; 54 *) 55 N=/etc/init.d/$NAME 56 echo "Usage: $N {start|stop|restart|force-reload}" >&2 57 exit 1 58 ;; 59esac 60 61exit 0 62