summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/dropbear/dropbear/init
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/dropbear/dropbear/init')
-rwxr-xr-xmeta/recipes-core/dropbear/dropbear/init26
1 files changed, 8 insertions, 18 deletions
diff --git a/meta/recipes-core/dropbear/dropbear/init b/meta/recipes-core/dropbear/dropbear/init
index f6e1c462fa..ffab7a2362 100755
--- a/meta/recipes-core/dropbear/dropbear/init
+++ b/meta/recipes-core/dropbear/dropbear/init
@@ -17,8 +17,11 @@ NAME=dropbear
17DESC="Dropbear SSH server" 17DESC="Dropbear SSH server"
18PIDFILE=/var/run/dropbear.pid 18PIDFILE=/var/run/dropbear.pid
19 19
20# These values may be replaced by those from /etc/default/dropbear
21DROPBEAR_RSAKEY_DIR="/etc/dropbear"
20DROPBEAR_PORT=22 22DROPBEAR_PORT=22
21DROPBEAR_EXTRA_ARGS= 23DROPBEAR_EXTRA_ARGS=
24DROPBEAR_RSAKEY_ARGS=
22NO_START=0 25NO_START=0
23 26
24set -e 27set -e
@@ -28,32 +31,19 @@ test "$NO_START" = "0" || exit 0
28test -x "$DAEMON" || exit 0 31test -x "$DAEMON" || exit 0
29test ! -h /var/service/dropbear || exit 0 32test ! -h /var/service/dropbear || exit 0
30 33
31readonly_rootfs=0
32for flag in `awk '{ if ($2 == "/") { split($4,FLAGS,",") } }; END { for (f in FLAGS) print FLAGS[f] }' </proc/mounts`; do
33 case $flag in
34 ro)
35 readonly_rootfs=1
36 ;;
37 esac
38done
39
40if [ $readonly_rootfs = "1" ]; then
41 mkdir -p /var/lib/dropbear
42 DROPBEAR_RSAKEY_DEFAULT="/var/lib/dropbear/dropbear_rsa_host_key"
43else
44 DROPBEAR_RSAKEY_DEFAULT="/etc/dropbear/dropbear_rsa_host_key"
45fi
46
47test -z "$DROPBEAR_BANNER" || \ 34test -z "$DROPBEAR_BANNER" || \
48 DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER" 35 DROPBEAR_EXTRA_ARGS="$DROPBEAR_EXTRA_ARGS -b $DROPBEAR_BANNER"
49test -n "$DROPBEAR_RSAKEY" || \ 36test -n "$DROPBEAR_RSAKEY" || \
50 DROPBEAR_RSAKEY=$DROPBEAR_RSAKEY_DEFAULT 37 DROPBEAR_RSAKEY="${DROPBEAR_RSAKEY_DIR}/dropbear_rsa_host_key"
51 38
52gen_keys() { 39gen_keys() {
53 if [ -f "$DROPBEAR_RSAKEY" -a ! -s "$DROPBEAR_RSAKEY" ]; then 40 if [ -f "$DROPBEAR_RSAKEY" -a ! -s "$DROPBEAR_RSAKEY" ]; then
54 rm $DROPBEAR_RSAKEY || true 41 rm $DROPBEAR_RSAKEY || true
55 fi 42 fi
56 test -f $DROPBEAR_RSAKEY || dropbearkey -t rsa -f $DROPBEAR_RSAKEY $DROPBEAR_RSAKEY_ARGS 43 if [ ! -f "$DROPBEAR_RSAKEY" ]; then
44 mkdir -p ${DROPBEAR_RSAKEY%/*}
45 dropbearkey -t rsa -f $DROPBEAR_RSAKEY $DROPBEAR_RSAKEY_ARGS
46 fi
57} 47}
58 48
59case "$1" in 49case "$1" in