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