nodogsplash: wait for interface to appear
authorMoritz Warning <moritzwarning@web.de>
Tue, 1 Nov 2016 01:13:49 +0000 (02:13 +0100)
committerMoritz Warning <moritzwarning@web.de>
Tue, 1 Nov 2016 01:13:49 +0000 (02:13 +0100)
nodogsplash/Makefile
nodogsplash/files/nodogsplash.init

index 2b8efd2a51dbe6c4722fb6f45dd2d55073d34f16..971fbac8fe783ee5efc1c2302e147f92127933bb 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=nodogsplash
 PKG_FIXUP:=autoreconf
 PKG_VERSION:=1.0.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
index f3df6a14f20b0b1300e5fa46e16f5b28351dd8ec..85bcfccf94de2332dabde98cd63e3878d789ccd1 100755 (executable)
@@ -119,6 +119,22 @@ setup_firewall() {
   done
 }
 
+wait_for_interface()
+{
+  local ifname="$1"
+  local timeout=10
+  for i in $(seq $timeout); do
+    if [ $(ip -4 addr show dev $ifname 2> /dev/null | grep -c inet) -ne 0 ]; then
+      break
+    fi
+    sleep 1
+    if [ $i == $timeout ] ; then
+      nolog error "$ifname not detected, NoDogSplash not starting."
+      exit 1
+    fi
+  done
+}
+
 generate_uci_config() {
   local cfg="$1"
   local val
@@ -161,6 +177,8 @@ generate_uci_config() {
       return 1
   fi
 
+  wait_for_interface "$ifname"
+
   echo "GatewayInterface $ifname" >> $CONFIGFILE
 
   append_config_option "$CONFIGFILE" "$cfg" gatewayname