]> TLD Linux GIT Repositories - rc-scripts.git/blobdiff - lib/ifdown-bond
- version 0.5.4
[rc-scripts.git] / lib / ifdown-bond
index 1d81ecb548e88f0432e0c6b29a619df6810211ef..f490bbe69fb645591faa0d18eaa8fc7d3cd3cf69 100755 (executable)
@@ -35,19 +35,19 @@ fi
 setup_ip_param
 
 # forget all addresses
-LC_ALL=C ip addr flush dev ${DEVICE} 2>&1 | grep -v "Nothing to flush"
+LC_ALL=C ip addr flush dev "${DEVICE}" 2>&1 | grep -v "Nothing to flush"
 
 # release slave devices
-for SLAVE_DEV in $(cat /sys/class/net/${DEVICE}/bonding/slaves); do
-       echo "-${SLAVE_DEV}" > /sys/class/net/${DEVICE}/bonding/slaves
+for SLAVE_DEV in $(cat /sys/class/net/${DEVICE}/bonding/slaves 2>/dev/null); do
+       ip link set "${SLAVE_DEV}" nomaster
 done
 
 # bring bonding master down
-ip link set ${DEVICE} down
+ip link set "${DEVICE}" down
 
 # remove bonding master
-if grep -wq "${DEVICE}" /sys/class/net/bonding_masters; then
-       echo "-${DEVICE}" > /sys/class/net/bonding_masters
+if [ -d "/sys/class/net/${DEVICE}" ]; then
+       ip link del "${DEVICE}" type bond
        if [ $? -ne 0 ]; then
                exit 1
        fi