diff options
| author | Jiří Prchal <jiri.prchal@aksignal.cz> | 2018-10-04 09:02:27 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-10-30 12:05:03 +0100 |
| commit | 47839ae6797bcded0178893cb950d2e2f8be1f6f (patch) | |
| tree | 9bb64f377d0c9d2be3b2bc1fe2b2e6357ed579e7 /examples | |
| parent | c05aa6a776ab2420a42c041a3b5d45db587fd9ef (diff) | |
| download | busybox-w32-47839ae6797bcded0178893cb950d2e2f8be1f6f.tar.gz busybox-w32-47839ae6797bcded0178893cb950d2e2f8be1f6f.tar.bz2 busybox-w32-47839ae6797bcded0178893cb950d2e2f8be1f6f.zip | |
examples/udhcp/simple.script: add possibility to use modern "ip"
Script uses "ifconfig" only, not up-to-date so much.
This patch adds "ip" in condition if exists.
Signed-off-by: Jiří Prchal <jiri.prchal@aksignal.cz>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/udhcp/simple.script | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/examples/udhcp/simple.script b/examples/udhcp/simple.script index e4c1f2d76..44aa46ece 100755 --- a/examples/udhcp/simple.script +++ b/examples/udhcp/simple.script | |||
| @@ -6,19 +6,31 @@ RESOLV_CONF="/etc/resolv.conf" | |||
| 6 | [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; } | 6 | [ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; } |
| 7 | 7 | ||
| 8 | NETMASK="" | 8 | NETMASK="" |
| 9 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | 9 | if command -v ip >/dev/null; then |
| 10 | [ -n "$subnet" ] && NETMASK="/$subnet" | ||
| 11 | else | ||
| 12 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | ||
| 13 | fi | ||
| 10 | BROADCAST="broadcast +" | 14 | BROADCAST="broadcast +" |
| 11 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | 15 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" |
| 12 | 16 | ||
| 13 | case "$1" in | 17 | case "$1" in |
| 14 | deconfig) | 18 | deconfig) |
| 15 | echo "Setting IP address 0.0.0.0 on $interface" | 19 | echo "Setting IP address 0.0.0.0 on $interface" |
| 16 | ifconfig $interface 0.0.0.0 | 20 | if command -v ip >/dev/null; then |
| 21 | ip addr flush dev $interface | ||
| 22 | else | ||
| 23 | ifconfig $interface 0.0.0.0 | ||
| 24 | fi | ||
| 17 | ;; | 25 | ;; |
| 18 | 26 | ||
| 19 | renew|bound) | 27 | renew|bound) |
| 20 | echo "Setting IP address $ip on $interface" | 28 | echo "Setting IP address $ip on $interface" |
| 21 | ifconfig $interface $ip $NETMASK $BROADCAST | 29 | if command -v ip >/dev/null; then |
| 30 | ip addr add $ip$NETMASK $BROADCAST dev $interface | ||
| 31 | else | ||
| 32 | ifconfig $interface $ip $NETMASK $BROADCAST | ||
| 33 | fi | ||
| 22 | 34 | ||
| 23 | if [ -n "$router" ] ; then | 35 | if [ -n "$router" ] ; then |
| 24 | echo "Deleting routers" | 36 | echo "Deleting routers" |
