From 9007efd01278bed6290f74af74b5abb86b3dfd0f Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 12 Dec 2020 10:36:55 -0500 Subject: /usr/share/udhcpc/default.script: Support both --- (limited to 'src.usr/share/udhcpc') 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' -- cgit v0.9.1