summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-03-16 13:42:48 +0000
committerAlyssa Ross <hi@alyssa.is>2023-03-16 13:42:48 +0000
commit4f820899cf6674e472303a06865515a94714cf60 (patch)
tree35a355002ebcaeb6319be3cbe1b86e0b17620a6c
parente245725619bbd50917162587019775a63290519c (diff)
downloadspectrum-4f820899cf6674e472303a06865515a94714cf60.tar
spectrum-4f820899cf6674e472303a06865515a94714cf60.tar.gz
spectrum-4f820899cf6674e472303a06865515a94714cf60.tar.bz2
spectrum-4f820899cf6674e472303a06865515a94714cf60.tar.lz
spectrum-4f820899cf6674e472303a06865515a94714cf60.tar.xz
spectrum-4f820899cf6674e472303a06865515a94714cf60.tar.zst
spectrum-4f820899cf6674e472303a06865515a94714cf60.zip
img/app: don't block mdev while waiting for online
Signed-off-by: Alyssa Ross <hi@alyssa.is>
-rwxr-xr-ximg/app/etc/mdev/iface54
1 files changed, 28 insertions, 26 deletions
diff --git a/img/app/etc/mdev/iface b/img/app/etc/mdev/iface
index 93a12eb..e85b4dd 100755
--- a/img/app/etc/mdev/iface
+++ b/img/app/etc/mdev/iface
@@ -2,35 +2,37 @@
 # SPDX-License-Identifier: EUPL-1.2+
 # SPDX-FileCopyrightText: 2020-2022 Alyssa Ross <hi@alyssa.is>
 
-importas -i INTERFACE INTERFACE
+background {
+  importas -i INTERFACE INTERFACE
 
-if { test $INTERFACE != lo }
+  if { test $INTERFACE != lo }
 
-# Our IP is encoded in the NIC-specific portion of the interface's MAC
-# address.
-backtick -E LOCAL_IP {
-  awk -F: "{printf \"100.64.%d.%d\\n\", \"0x\" $5, \"0x\" $6}"
-  /sys/class/net/${INTERFACE}/address
-}
+  # Our IP is encoded in the NIC-specific portion of the interface's MAC
+  # address.
+  backtick -E LOCAL_IP {
+    awk -F: "{printf \"100.64.%d.%d\\n\", \"0x\" $5, \"0x\" $6}"
+    /sys/class/net/${INTERFACE}/address
+  }
 
-if { ip address add ${LOCAL_IP}/32 dev $INTERFACE }
-if { ip link set $INTERFACE up }
-if { ip route add 169.254.0.1 dev $INTERFACE }
-if { ip route add default via 169.254.0.1 dev $INTERFACE }
+  if { ip address add ${LOCAL_IP}/32 dev $INTERFACE }
+  if { ip link set $INTERFACE up }
+  if { ip route add 169.254.0.1 dev $INTERFACE }
+  if { ip route add default via 169.254.0.1 dev $INTERFACE }
 
-# Try to wait for the network to be up.
-# If we time out, well, there's not much we can do, so just carry on.
-# In future, it would be better if the network VM notified us about
-# network changes.
-foreground { printf "Waiting for network… " }
-foreground {
-  ifte { echo "Connected." } { echo "Timed out." }
-  pipeline { seq 10 }
-  forstdin _
-  if -n {
-    redirfd -w 2 /dev/null
-    wget -qT 6 -O /dev/null http://ipv4.connman.net/online/status.html
+  # Try to wait for the network to be up.
+  # If we time out, well, there's not much we can do, so just carry on.
+  # In future, it would be better if the network VM notified us about
+  # network changes.
+  foreground { printf "Waiting for network… " }
+  foreground {
+    ifte { echo "Connected." } { echo "Timed out." }
+    pipeline { seq 10 }
+    forstdin _
+    if -n {
+      redirfd -w 2 /dev/null
+      wget -qT 6 -O /dev/null http://ipv4.connman.net/online/status.html
+    }
   }
-}
 
-/etc/mdev/listen network-online
+  /etc/mdev/listen network-online
+}