Merge "Support adding DHCP interfaces one at a time."
This commit is contained in:
commit
0d52928a53
@ -1,7 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
INTERFACE=$1 #optional, if not specified configure all available interfaces
|
||||||
ENI_FILE="/etc/network/interfaces"
|
ENI_FILE="/etc/network/interfaces"
|
||||||
|
|
||||||
|
PATH=/bin:/sbin:$PATH
|
||||||
|
|
||||||
if [ -d "/etc/network" ]; then
|
if [ -d "/etc/network" ]; then
|
||||||
CONF_TYPE="eni"
|
CONF_TYPE="eni"
|
||||||
elif [ -d "/etc/sysconfig/network-scripts/" ]; then
|
elif [ -d "/etc/sysconfig/network-scripts/" ]; then
|
||||||
@ -63,16 +66,17 @@ function config_exists() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
for interface in $(ls /sys/class/net | grep -v ^lo$) ; do
|
function inspect_interface() {
|
||||||
MAC_ADDR_TYPE="$(cat /sys/class/net/${interface}/addr_assign_type)"
|
local interface=$1
|
||||||
|
local mac_addr_type="$(cat /sys/class/net/${interface}/addr_assign_type)"
|
||||||
|
|
||||||
echo -n "Inspecting interface: $interface..."
|
echo -n "Inspecting interface: $interface..."
|
||||||
if config_exists $interface; then
|
if config_exists $interface; then
|
||||||
echo "Has config, skipping."
|
echo "Has config, skipping."
|
||||||
elif [ "$MAC_ADDR_TYPE" != "0" ]; then
|
elif [ "$mac_addr_type" != "0" ]; then
|
||||||
echo "Device has generated MAC, skipping."
|
echo "Device has generated MAC, skipping."
|
||||||
else
|
else
|
||||||
ip link set dev $interface up >/dev/null 2>&1
|
ip link set dev $interface up &>/dev/null
|
||||||
HAS_LINK="$(get_if_link $interface)"
|
HAS_LINK="$(get_if_link $interface)"
|
||||||
|
|
||||||
TRIES=10
|
TRIES=10
|
||||||
@ -91,4 +95,13 @@ for interface in $(ls /sys/class/net | grep -v ^lo$) ; do
|
|||||||
disable_interface "$interface"
|
disable_interface "$interface"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "$INTERFACE" ]; then
|
||||||
|
inspect_interface $INTERFACE
|
||||||
|
else
|
||||||
|
for iface in $(ls /sys/class/net | grep -v ^lo$); do
|
||||||
|
inspect_interface $iface
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user