diff options
| author | Roy Marples <roy@marples.name> | 2008-09-09 17:07:48 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2008-09-09 17:07:48 +0000 |
| commit | 2b60ecb71e76e4a6ac765afac3ce7da87ef4464b (patch) | |
| tree | 968c8817e04c5120bd31ed433f3aed92a0471a1a /dhcpcd-run-hooks.in | |
| parent | 21164dfb798aedb56d11bcdca897106748094d91 (diff) | |
| download | dhcpcd-2b60ecb71e76e4a6ac765afac3ce7da87ef4464b.tar.xz | |
Sort interfaces according to preference and pass this to dhcpcd-run-hooks so we can prefer configs.
Diffstat (limited to 'dhcpcd-run-hooks.in')
| -rw-r--r-- | dhcpcd-run-hooks.in | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index 1e5d5b37..c18bd272 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -25,15 +25,26 @@ uniqify() } # List interface config files in a dir -# We may wish to control the order at some point rather than just lexical +# If dhcpcd is running as a single instance then it will have a list of +# interfaces in the preferred order. +# Otherwise we just use what we have. list_interfaces() { - local x= interfaces= + local i= x= ifaces= + for i in ${interface_order}; do + [ -e "$1"/${i} ] && ifaces="${ifaces}${ifaces:+ }${i}" + done for x in "$1"/*; do [ -e "${x}" ] || continue - interfaces="${interfaces}${interfaces:+ }${x##*/}" + for i in ${interface_order}; do + if [ ${i} = "${x##*/}" ]; then + unset x + break + fi + done + [ -n "${x}" ] && ifaces="${ifaces}${ifaces:+ }${x##*/}" done - echo "${interfaces}" + echo "${ifaces}" } # We normally use sed to extract values using a key from a list of files |
