diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-15 20:36:23 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-15 21:04:08 +0000 |
commit | 01e62c2fa4fdc836d340ee47cd079c4d611763a2 (patch) | |
tree | 22e81f0165aae37ccdaa9693abe94744183f282d /main/busybox-initscripts | |
parent | d2b7964762199998966a0473e65b72624d54411e (diff) | |
download | aports-01e62c2fa4fdc836d340ee47cd079c4d611763a2.tar.bz2 aports-01e62c2fa4fdc836d340ee47cd079c4d611763a2.tar.xz |
main/busybox-initscripts: support multiple dhcp interfaces
We set the metric to 300 + ifindex for wifi and 200 + ifindex for
others. This is basically what dhcpcd does.
Also allow overriding the metric in interfaces file.
This makes multi isp setups easier.
Diffstat (limited to 'main/busybox-initscripts')
-rw-r--r-- | main/busybox-initscripts/APKBUILD | 4 | ||||
-rw-r--r-- | main/busybox-initscripts/default.script | 27 |
2 files changed, 25 insertions, 6 deletions
diff --git a/main/busybox-initscripts/APKBUILD b/main/busybox-initscripts/APKBUILD index f5d0b5abd0..cafe3cca13 100644 --- a/main/busybox-initscripts/APKBUILD +++ b/main/busybox-initscripts/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=busybox-initscripts pkgver=2.2 -pkgrel=4 +pkgrel=5 pkgdesc="Init scripts for busybox daemons" url="http://git.alpinelinux.org/cgit/aports/tree/core/busybox-initscripts" arch="noarch" @@ -73,4 +73,4 @@ ad1556961294e4aa2abca6be52138b7c dvbdev c422992ca5bfdfabdbba1f1532bc1358 usbdev 30b0c85956b6701caf55309a17e537f6 usbdisk_link 826d85313ca7a4a0205d63bd58b7d01f xvd_links -c92e18e9d47f4a2a6ca6b3a81ea2f838 default.script" +de1f58a6f840fd2ea2767583c91aa19f default.script" diff --git a/main/busybox-initscripts/default.script b/main/busybox-initscripts/default.script index c6cfbc5be1..5447080ec9 100644 --- a/main/busybox-initscripts/default.script +++ b/main/busybox-initscripts/default.script @@ -34,16 +34,35 @@ deconfig() { ip addr flush dev $interface } +is_wifi() { + test -e /sys/class/net/$interface/phy80211 +} + +if_index() { + cat /sys/class/net/$interface/ifindex +} + +calc_metric() { + local base= + if is_wifi; then + base=300 + else + base=200 + fi + echo $(( $base + $(if_index) )) +} + routes() { [ -z "$router" ] && return - local gw metric + local gw= num= while ip route del default via dev $interface 2>/dev/null; do : done - metric=0 + num=0 for gw in $router; do - route add default gw $gw dev $interface metric $metric - metric=$(( $metric + 1 )) + ip route add 0.0.0.0/0 via $gw dev $interface \ + metric $(( $num + ${IF_METRIC:-$(calc_metric)} )) + num=$(( $num + 1 )) done } |