1#!/bin/sh 2# 3# Starts dropbear sshd. 4# 5 6# Allow a few customizations from a config file 7test -r /etc/default/dropbear && . /etc/default/dropbear 8 9start() { 10 DROPBEAR_ARGS="$DROPBEAR_ARGS -R" 11 12 # If /etc/dropbear is a symlink to /var/run/dropbear, and 13 # - the filesystem is RO (i.e. we can not rm the symlink), 14 # create the directory pointed to by the symlink. 15 # - the filesystem is RW (i.e. we can rm the symlink), 16 # replace the symlink with an actual directory 17 if [ -L /etc/dropbear \ 18 -a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ] 19 then 20 if rm -f /etc/dropbear >/dev/null 2>&1; then 21 mkdir -p /etc/dropbear 22 else 23 echo "No persistent location to store SSH host keys. New keys will be" 24 echo "generated at each boot. Are you sure this is what you want to do?" 25 mkdir -p "$(readlink /etc/dropbear)" 26 fi 27 fi 28 29 printf "Starting dropbear sshd: " 30 umask 077 31 32 start-stop-daemon -S -q -p /var/run/dropbear.pid \ 33 --exec /usr/sbin/dropbear -- $DROPBEAR_ARGS 34 [ $? = 0 ] && echo "OK" || echo "FAIL" 35} 36stop() { 37 printf "Stopping dropbear sshd: " 38 start-stop-daemon -K -q -p /var/run/dropbear.pid 39 [ $? = 0 ] && echo "OK" || echo "FAIL" 40} 41restart() { 42 stop 43 start 44} 45 46case "$1" in 47 start) 48 start 49 ;; 50 stop) 51 stop 52 ;; 53 restart|reload) 54 restart 55 ;; 56 *) 57 echo "Usage: $0 {start|stop|restart}" 58 exit 1 59esac 60 61exit $? 62