# BRCM_VERSION=3
[bcm963xx.git] / userapps / opensource / sshd / debian / dropbear.init
1 #! /bin/sh
2 #
3 # skeleton      example file to build /etc/init.d/ scripts.
4 #               This file should be used to construct scripts for /etc/init.d.
5 #
6 #               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
7 #               Modified for Debian 
8 #               by Ian Murdock <imurdock@gnu.ai.mit.edu>.
9 #
10 # Version:      @(#)skeleton  1.9  26-Feb-2001  miquels@cistron.nl
11 #
12
13 #
14 # Do not configure this file. Edit /etc/default/dropbear instead!
15 #
16
17 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18 DAEMON=/usr/sbin/dropbear
19 NAME=dropbear
20 DESC="Dropbear SSH server"
21
22 DROPBEAR_PORT=22
23 DROPBEAR_EXTRA_ARGS=
24 NO_START=0
25 set -e
26 test -f /etc/default/dropbear && . /etc/default/dropbear
27
28 if [ -n "$DROPBEAR_BANNER" ]; then
29         DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER"
30 fi
31
32 if [ -z "$DROPBEAR_RSAKEY" ]; then
33         DROPBEAR_RSAKEY="/etc/dropbear/dropbear_rsa_host_key"
34 fi
35
36 if [ -z "$DROPBEAR_DSSKEY" ]; then
37         DROPBEAR_DSSKEY="/etc/dropbear/dropbear_dss_host_key"
38 fi
39
40 test "$NO_START" != "0" && exit 0
41
42 test -x $DAEMON || exit 0
43
44 case "$1" in
45   start)
46         echo -n "Starting $DESC: "
47         start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
48                 --exec $DAEMON -- -d $DROPBEAR_DSSKEY -r $DROPBEAR_RSAKEY -p $DROPBEAR_PORT $DROPBEAR_EXTRA_ARGS
49         echo "$NAME."
50         ;;
51   stop)
52         echo -n "Stopping $DESC: "
53         start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/$NAME.pid
54         echo "$NAME."
55         ;;
56   restart|force-reload)
57         #
58         #       If the "reload" option is implemented, move the "force-reload"
59         #       option to the "reload" entry above. If not, "force-reload" is
60         #       just the same as "restart".
61         #
62         echo -n "Restarting $DESC: "
63         start-stop-daemon --stop --quiet --oknodo --pidfile \
64                 /var/run/$NAME.pid
65         sleep 1
66         start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
67                 --exec $DAEMON -- -d $DROPBEAR_DSSKEY -r $DROPBEAR_RSAKEY -p $DROPBEAR_PORT $DROPBEAR_EXTRA_ARGS
68         echo "$NAME."
69         ;;
70   *)
71         N=/etc/init.d/$NAME
72         # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
73         echo "Usage: $N {start|stop|restart|force-reload}" >&2
74         exit 1
75         ;;
76 esac
77
78 exit 0