fix the sdk
[openwrt.git] / package / dropbear / files / dropbear.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3 # Copyright (C) 2006 Carlos Sobrinho
4
5 config_cb() {
6 local cfg="$CONFIG_SECTION"
7 local nopasswd
8 local cfgt
9 config_get cfgt "$cfg" TYPE
10
11 case "$cfgt" in
12 dropbear)
13 config_get passauth $cfg PasswordAuth
14 config_get port $cfg Port
15
16 case "$passauth" in
17 no|off|disabled|0) nopasswd=1;;
18 esac
19 DROPBEAR_ARGS="${nopasswd:+-s }${port:+-p $port}"
20 ;;
21 esac
22 }
23
24 keygen() {
25 for keytype in rsa dss; do
26 # check for keys
27 key=dropbear/dropbear_${keytype}_host_key
28 [ -f /tmp/$key -o -f /etc/$key ] || {
29 # generate missing keys
30 mkdir -p /tmp/dropbear
31 [ -x /usr/bin/dropbearkey ] && {
32 /usr/bin/dropbearkey -t $keytype -f /tmp/$key 2>&- >&- && exec /etc/rc.common "$initscript" start
33 } &
34 exit 0
35 }
36 done
37
38 lock /tmp/.switch2jffs
39 mkdir -p /etc/dropbear
40 mv /tmp/dropbear/dropbear_* /etc/dropbear/
41 lock -u /tmp/.switch2jffs
42 chown root /etc/dropbear
43 chmod 0700 /etc/dropbear
44 }
45
46 start() {
47 [ -f /etc/dropbear/dropbear_rsa_host_key -a \
48 -f /etc/dropbear/dropbear_dss_host_key ] || keygen
49
50 config_load dropbear
51 /usr/sbin/dropbear $DROPBEAR_ARGS
52 }
53
54 stop() {
55 killall dropbear
56 }
This page took 0.050355 seconds and 5 git commands to generate.