diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2020-12-12 10:36:55 (EST) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2020-12-12 10:36:55 (EST) |
commit | 9007efd01278bed6290f74af74b5abb86b3dfd0f (patch) | |
tree | c4f6130f8e606cf1d0467b49cf1d098014228bfa | |
parent | 522e0d787a9e6290341c022e9a879b74ec9ecd58 (diff) |
/usr/share/udhcpc/default.script: Support both
-rw-r--r-- | changelog | 3 | ||||
-rwxr-xr-x | src.usr/share/udhcpc/default.script | 20 |
2 files changed, 18 insertions, 5 deletions
@@ -1,6 +1,7 @@ busybox (1.32.0-3) trunk - * A default gateway is no longer missing. + * </usr/share/udhcpc/default.script> now supports the "ip route" + command in case "route" is disabled. -- Patrick McDermott <patrick.mcdermott@libiquity.com> Sat, 12 Dec 2020 10:09:01 -0500 diff --git a/src.usr/share/udhcpc/default.script b/src.usr/share/udhcpc/default.script index bb27ec0..e88ccef 100755 --- a/src.usr/share/udhcpc/default.script +++ b/src.usr/share/udhcpc/default.script @@ -1,5 +1,18 @@ #!/bin/sh +route() +{ + local cmd="${1}" + local tgt="${2}" + shift 2 + + if [ -x /sbin/ip ]; then + /sbin/ip route "${cmd}" "${tgt}" via "${@}" + elif [ -x /sbin/route ]; then + /sbin/route "${cmd}" "${tgt}" gw "${@}" + fi +} + case "${1}" in 'deconfig') /sbin/ifconfig "${interface}" 0.0.0.0 @@ -9,13 +22,12 @@ case "${1}" in ${broadcast+broadcast ${broadcast}} \ ${netmask+netmask ${netmask}} if [ "x${router+set}" = 'xset' ]; then - while /sbin/ip route del default via 0.0.0.0 \ - dev "${interface}" 2>/dev/null; do + while route del default 0.0.0.0 dev "${interface}" \ + 2>/dev/null; do : done for router in ${router}; do - /sbin/ip route add default via "${router}" \ - dev "${interface}" + route add default "${router}" dev "${interface}" done fi exec 3>'/etc/resolv.conf' |