Merge "Change filename parsing to ip output"

This commit is contained in:
Jenkins 2016-02-19 07:44:44 +00:00 committed by Gerrit Code Review
commit afe82e5804
1 changed files with 14 additions and 6 deletions

View File

@ -159,30 +159,38 @@ function get_ifcfg_value {
echo ${value} echo ${value}
} }
# Get IP address from interface name
function get_interface_ip {
local interface=$1
echo $(ip -4 -o a s ${interface} | sed 's:/:\ :;s:\s\+:\ :g' | cut -d ' ' -f 4)
}
# Workaround to fix dracut network configuration approach: # Workaround to fix dracut network configuration approach:
# Bring down all network interfaces which have the same IP # Bring down all network interfaces which have the same IP
# address statically configured as 'primary' interface # address statically configured as 'primary' interface
function ifdown_ethernet_interfaces { function ifdown_ethernet_interfaces {
local adminif_ipaddr local adminif_ipaddr
local if_config
local if_name local if_name
local if_ipaddr local if_ipaddr
local path
adminif_ipaddr=$(get_ifcfg_value IPADDR /etc/sysconfig/network-scripts/ifcfg-${ADMIN_INTERFACE}) adminif_ipaddr=$(get_interface_ip $ADMIN_INTERFACE)
if [[ -z "${adminif_ipaddr}" ]]; then if [[ -z "${adminif_ipaddr}" ]]; then
return return
fi fi
for if_config in $(find /etc/sysconfig/network-scripts -name 'ifcfg-*' ! -name 'ifcfg-lo'); do for if_name in $(get_ethernet_interfaces); do
if_name=$(get_ifcfg_value NAME $if_config)
if [[ "${if_name}" == "${ADMIN_INTERFACE}" ]]; then if [[ "${if_name}" == "${ADMIN_INTERFACE}" ]]; then
continue continue
fi fi
if_ipaddr=$(get_ifcfg_value IPADDR $if_config) if_ipaddr=$(get_interface_ip $if_name)
if [[ "${if_ipaddr}" == "${adminif_ipaddr}" ]]; then if [[ "${if_ipaddr}" == "${adminif_ipaddr}" ]]; then
echo "Interface '${if_name}' uses the same ip '${if_ipaddr}' as admin interface '${ADMIN_INTERFACE}', removing ..." echo "Interface '${if_name}' uses the same ip '${if_ipaddr}' as admin interface '${ADMIN_INTERFACE}', removing ..."
ifdown ${if_name} ifdown ${if_name}
mkdir -p "${bup_folder}" mkdir -p "${bup_folder}"
mv -f "${if_config}" "${bup_folder}" path="/etc/sysconfig/network-scripts/ifcfg-${if_name}"
if [[ -f ${path} ]]; then
mv -f "${path}" "${bup_folder}"
fi
fi fi
done done
} }