bring up to date with nbd's br2_test20.tar.bz2
[openwrt/svn-archive/archive.git] / openwrt / package / dropbear / files / S50dropbear
1 #!/bin/sh
2 #
3 # Starts dropbear sshd.
4 #
5
6 # Make sure the dropbearkey progam exists
7 [ -f /usr/bin/dropbearkey ] || exit 0
8
9 # Check for the Dropbear RSA key
10 if [ ! -f /etc/dropbear/dropbear_rsa_host_key ] ; then
11 (
12 echo Generating RSA Key...
13 mkdir -p /etc/dropbear
14 /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
15 [ -f /etc/dropbear/dropbear_rsa_host_key ] && exec $0 $*
16 ) > /dev/null 2> /dev/null &
17 exit 0
18 fi
19
20 # Check for the Dropbear DSS key
21 if [ ! -f /etc/dropbear/dropbear_dss_host_key ] ; then
22 (
23 echo Generating DSS Key...
24 mkdir -p /etc/dropbear
25 /usr/bin/dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
26 [ -f /etc/dropbear/dropbear_dss_host_key ] && exec $0 $*
27 ) > /dev/null 2> /dev/null &
28 exit 0
29 fi
30
31 umask 077
32
33 start() {
34 echo -n "Starting dropbear sshd: "
35 start-stop-daemon --start --quiet --pidfile /var/run/dropbear.pid --exec /usr/sbin/dropbear
36 echo "OK"
37 }
38 stop() {
39 echo -n "Stopping dropbear sshd: "
40 start-stop-daemon --stop --quiet --pidfile /var/run/dropbear.pid
41 echo "OK"
42 }
43 restart() {
44 stop
45 start
46 }
47
48 case "$1" in
49 start)
50 start
51 ;;
52 stop)
53 stop
54 ;;
55 restart|reload)
56 restart
57 ;;
58 *)
59 echo $"Usage: $0 {start|stop|restart}"
60 exit 1
61 esac
62
63 exit $?
64