olsrd: wait for wireless to initialize before starting
authorPerry Melange <isprotejesvalkata@gmail.com>
Tue, 12 Oct 2021 16:17:08 +0000 (18:17 +0200)
committerNick Hainke <vincent@systemli.org>
Wed, 13 Oct 2021 07:11:14 +0000 (09:11 +0200)
Wait for wireless to initialize (pending="false") to ensure
that any olsrd(6) configured interfaces and their associated
devices are up.  This provides the init script the ability
to properly add all interface sections to the generated
config file /tmp/etc/olsrd(6).conf

Signed-off-by: Perry Melange <isprotejesvalkata@gmail.com>
olsrd/files/olsrd4.init
olsrd/files/olsrd6.init

index 28a84a647bcdae5872c1ced3ff03135ca3834827..62cb66d6ffac32834552789f073fc3e859cce344 100644 (file)
@@ -15,10 +15,24 @@ wait_for_network()
        ubus -t 15 wait_for network.interface.$1 2>/dev/null
 }
 
+wait_for_wireless()
+{
+       local count=0
+       ubus -t 15 wait_for network.wireless 2>/dev/null
+       while [ $count -lt 30 ]; do
+               if  [ "$(ubus call network.wireless status | jsonfilter -e '@[*]["pending"]' | grep true | wc -l)" == "0" ]; then
+                       break
+               fi
+               count=$((count+1))
+               sleep 1
+       done
+}
+
 boot()
 {
        config_load network
        config_foreach wait_for_network interface
+       wait_for_wireless
        rc_procd start_service
 }
 
index 8f9b91acc807a8abce13182274c75280285d8ad8..a20e96728aff1a7ce162d5d83a6f440b249c5a86 100644 (file)
@@ -15,10 +15,24 @@ wait_for_network()
        ubus -t 15 wait_for network.interface.$1 2>/dev/null
 }
 
+wait_for_wireless()
+{
+       local count=0
+       ubus -t 15 wait_for network.wireless 2>/dev/null
+       while [ $count -lt 30 ]; do
+               if  [ "$(ubus call network.wireless status | jsonfilter -e '@[*]["pending"]' | grep true | wc -l)" == "0" ]; then
+                       break
+               fi
+               count=$((count+1))
+               sleep 1
+       done
+}
+
 boot()
 {
        config_load network
        config_foreach wait_for_network interface
+       wait_for_wireless
        rc_procd start_service
 }