aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xexamples/udhcp/simple.script18
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
8NETMASK="" 8NETMASK=""
9[ -n "$subnet" ] && NETMASK="netmask $subnet" 9if command -v ip >/dev/null; then
10 [ -n "$subnet" ] && NETMASK="/$subnet"
11else
12 [ -n "$subnet" ] && NETMASK="netmask $subnet"
13fi
10BROADCAST="broadcast +" 14BROADCAST="broadcast +"
11[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" 15[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
12 16
13case "$1" in 17case "$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"