diff options
-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 } |