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