diff options
Diffstat (limited to 'sysconfig')
-rwxr-xr-x | sysconfig/network-scripts/ifdown | 7 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup | 7 | ||||
-rwxr-xr-x | sysconfig/network-scripts/ifup-eth | 2 | ||||
-rw-r--r-- | sysconfig/network-scripts/network-functions | 43 |
4 files changed, 53 insertions, 6 deletions
diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown index a0cc0c9e..fd766427 100755 --- a/sysconfig/network-scripts/ifdown +++ b/sysconfig/network-scripts/ifdown @@ -16,7 +16,7 @@ CONFIG=$1 exit 1 } -need_config $CONFIG +need_config "${CONFIG}" [ -f "$CONFIG" ] || { echo $"usage: ifdown <device name>" >&2 @@ -41,6 +41,11 @@ then exit 0 fi +if [ "$USE_NM" = "true" ]] && is_nm_active "$DEVICE" ; then + nmcli dev disconnect iface "$DEVICE" + exit $? +fi + if [ -x /sbin/ifdown-pre-local ]; then /sbin/ifdown-pre-local ${DEVICE} fi diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup index e3b01478..cc5efc97 100755 --- a/sysconfig/network-scripts/ifup +++ b/sysconfig/network-scripts/ifup @@ -31,7 +31,7 @@ CONFIG=${1} exit 1 } -need_config ${CONFIG} +need_config "${CONFIG}" [ -f "${CONFIG}" ] || { echo $"$0: configuration for ${1} not found." >&2 @@ -65,6 +65,11 @@ then exit 0 fi +if [ "$USE_NM" = "true" -a -n "$UUID" ]; then + nmcli con up uuid "$UUID" + exit $? +fi + # Ethernet 802.1Q VLAN support if [ "${VLAN}" = "yes" ] && [ "$ISALIAS" = "no" ] && [ -x /sbin/vconfig ]; then VID="" diff --git a/sysconfig/network-scripts/ifup-eth b/sysconfig/network-scripts/ifup-eth index 17312863..51d1ae4f 100755 --- a/sysconfig/network-scripts/ifup-eth +++ b/sysconfig/network-scripts/ifup-eth @@ -24,7 +24,7 @@ cd /etc/sysconfig/network-scripts CONFIG=${1} -need_config ${CONFIG} +need_config "${CONFIG}" source_config diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 89baeb45..e498553b 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -20,6 +20,13 @@ get_hwaddr () fi } +get_config_by_device () +{ + LANG=C grep -l "^[[:space:]]*DEVICE=${1}\([[:space:]#]\|$\)" \ + /etc/sysconfig/network-scripts/ifcfg-* \ + | LC_ALL=C sed -e "$__sed_discard_ignored_files" +} + get_config_by_hwaddr () { LANG=C grep -il "^[[:space:]]*HWADDR=${1}\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-* \ @@ -34,11 +41,24 @@ get_config_by_subchannel () | LC_ALL=C sed -e "$__sed_discard_ignored_files" } +get_config_by_name () +{ + LANG=C grep -E -i -l \ + "^[[:space:]]*NAME=\"(Auto |System )?${1}\"" \ + /etc/sysconfig/network-scripts/ifcfg-* \ + | LC_ALL=C sed -e "$__sed_discard_ignored_files" +} + get_device_by_hwaddr () { LANG=C ip -o link | grep -v link/ieee802.11 | awk -F ': ' -vIGNORECASE=1 "/$1/ { print \$2 }" } +get_uuid_by_config () +{ + dbus-send --system --print-reply --dest=com.redhat.ifcfgrh1 /com/redhat/ifcfgrh1 com.redhat.ifcfgrh1.GetIfcfgDetails string:"/etc/sysconfig/network-scripts/$1" | awk -F '"' '/string / { print $2 }' +} + need_config () { local nconfig @@ -47,6 +67,11 @@ need_config () [ -f "${CONFIG}" ] && return CONFIG="${1##*/}" [ -f "${CONFIG}" ] && return + nconfig=$(get_config_by_name "${1}") + if [ -n "$nconfig" ] && [ -f "$nconfig" ]; then + CONFIG=${nconfig##*/} + return + fi local addr=$(get_hwaddr ${1}) if [ -n "$addr" ]; then nconfig=$(get_config_by_hwaddr ${addr}) @@ -55,9 +80,7 @@ need_config () [ -f "${CONFIG}" ] && return fi fi - nconfig=$(LANG=C grep -l "^[[:space:]]*DEVICE=${1}\([[:space:]#]\|$\)" \ - /etc/sysconfig/network-scripts/ifcfg-* \ - | LC_ALL=C sed -e "$__sed_discard_ignored_files") + nconfig=$(get_config_by_device ${1}) if [ -n "$nconfig" ] && [ -f "$nconfig" ]; then CONFIG=${nconfig##*/} return @@ -120,6 +143,10 @@ source_config () else ISALIAS=no fi + is_nm_running && USE_NM=true + if [ -z "$UUID" -a "$USE_NM" = "true" ]; then + UUID=$(get_uuid_by_config $CONFIG) + fi } @@ -172,6 +199,16 @@ do_netreport () ) } +is_nm_running () +{ + LANG=C nmcli nm status | grep -Eq "NM running:[[:space:]]+running" +} + +is_nm_active () +{ + LANG=C nmcli -t dev status | grep -Eq "^${1}[[:space:]]*.*[[:space:]]*connected" +} + # Sets $alias to the device module if $? != 0 is_available () { |