alfred: Support interface IDs with more than two digits 354/head
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>
Mon, 19 Mar 2018 13:16:54 +0000 (14:16 +0100)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Mon, 9 Apr 2018 10:11:12 +0000 (12:11 +0200)
Occationally /proc/net/if_inet6 contains interface IDs with
three digits. In this case, the regex in wait_for_ll_address()
does not work anymore and alfred is not starting.

This patch changes the evaluation so that fields are used instead
of the mere position by counting characters.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
alfred/files/alfred.init

index 4c9a9e195ada75d8f7b9d42e2b852cc855552bfb..8293436870af23914ce2cdcad26e0539d4b3667d 100755 (executable)
@@ -46,11 +46,11 @@ wait_for_ll_address()
        for i in $(seq $timeout); do
                # We look for
                # - the link-local address (starts with fe80)
-               # - without tentative flag (bit 0x40 in the flags field; the first char of the flags field begins 38 columns after the fe80 prefix
+               # - without tentative flag (bit 0x40 in the flags field; the first char of the fifth field is evaluated)
                # - on interface $iface
                if awk '
                        BEGIN { RET=1 }
-                       /^fe80.{37} [012389ab]/ { if ($6 == "'"$iface"'") RET=0 }
+                       $1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
                        END { exit RET }
                ' /proc/net/if_inet6; then
                        return