← Commit list

47839ae67

Jiří Prchal
Jiří Prchal
2018-10-30
SUCCESS Duration: 146s

Subject

examples/udhcp/simple.script: add possibility to use modern "ip"

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

examples/udhcp/simple.script+15 -3
@@ -6,19 +6,31 @@ RESOLV_CONF="/etc/resolv.conf"
[ -n "$1" ] || { echo "Error: should be called from udhcpc"; exit 1; }
NETMASK=""
-[ -n "$subnet" ] && NETMASK="netmask $subnet"
+if command -v ip >/dev/null; then
+ [ -n "$subnet" ] && NETMASK="/$subnet"
+else
+ [ -n "$subnet" ] && NETMASK="netmask $subnet"
+fi
BROADCAST="broadcast +"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
case "$1" in
deconfig)
echo "Setting IP address 0.0.0.0 on $interface"
- ifconfig $interface 0.0.0.0
+ if command -v ip >/dev/null; then
+ ip addr flush dev $interface
+ else
+ ifconfig $interface 0.0.0.0
+ fi
;;
renew|bound)
echo "Setting IP address $ip on $interface"
- ifconfig $interface $ip $NETMASK $BROADCAST
+ if command -v ip >/dev/null; then
+ ip addr add $ip$NETMASK $BROADCAST dev $interface
+ else
+ ifconfig $interface $ip $NETMASK $BROADCAST
+ fi
if [ -n "$router" ] ; then
echo "Deleting routers"