use locking to make sure that dropbear keys can be generated on the first boot
authorFelix Fietkau <nbd@openwrt.org>
Thu, 23 Mar 2006 16:15:45 +0000 (16:15 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 23 Mar 2006 16:15:45 +0000 (16:15 +0000)
SVN-Revision: 3468

openwrt/package/base-files/default/etc/init.d/S99done
openwrt/package/dropbear/files/S50dropbear

index 786a83f377dc2a71e9adeaca5448aeca69e0568d..e41d4e698c4244d41a5568d1ba00fce3815e0176 100755 (executable)
@@ -3,7 +3,11 @@ sysctl -p >&-
 
 # automagically run firstboot
 [ "$(nvram get no_root_swap)" != 1 ] && {
-       { mount|grep "on / type tmpfs" 1>&-; } && firstboot switch2jffs
+       { mount|grep "on / type tmpfs" 1>&-; } && {
+               lock /tmp/.switch2jffs
+               firstboot switch2jffs
+               lock -u /tmp/.switch2jffs
+       }
 }
 
 # set leds to normal state
index 88fc28849183a542024c52342eeb8e797dfb1d02..a4d6111bec5c5e690a6b37ce5864bf195e358ea0 100755 (executable)
@@ -1,16 +1,21 @@
 #!/bin/sh
 
-for type in rsa dss; do {
-  # check for keys
-  key=/etc/dropbear/dropbear_${type}_host_key
-  [ ! -f $key ] && {
-    # generate missing keys
-    mkdir -p /etc/dropbear
-    [ -x /usr/bin/dropbearkey ] && {
-      /usr/bin/dropbearkey -t $type -f $key 2>&- >&- && exec $0 $*
-    } &
-    exit 0
-  }
-}; done
+[ ! -f /etc/dropbear/dropbear_rsa_host_key ] && {
+       for type in rsa dss; do {
+               # check for keys
+               key=/tmp/dropbear/dropbear_${type}_host_key
+               [ ! -f $key ] && {
+                       # generate missing keys
+                       mkdir -p /tmp/dropbear
+                       [ -x /usr/bin/dropbearkey ] && {
+                               /usr/bin/dropbearkey -t $type -f $key 2>&- >&- && exec $0 $*
+                       } &
+                       exit 0
+               }
+       }; done
+       lock -w /tmp/.switch2jffs
+       mkdir -p /etc/dropbear
+       mv /tmp/dropbear/dropbear_* /etc/dropbear/
+}
 
 /usr/sbin/dropbear