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