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