dnsmasq: make the check for existing DHCP servers more reliable
[librecmc/librecmc.git] / package / network / services / dnsmasq / files / dnsmasq.init
index 3809e6c119ffc714517996ac916323162bb74194..0941f87fa8d028e8fc5aa6153bd402d80b31fde4 100644 (file)
@@ -64,6 +64,12 @@ dhcp_check() {
 
        [ -s "$stamp" ] && return $(cat "$stamp")
 
+       # If there's no carrier yet, skip this interface.
+       # The init script will be called again once the link is up
+       case "$(devstatus "$ifname" | jsonfilter -e @.carrier)" in
+               false) return 1;;
+       esac
+
        udhcpc -n -q -s /bin/true -t 1 -i "$ifname" >&- && rv=1 || rv=0
 
        [ $rv -eq 1 ] && \