diff options
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r-- | sysconfig/network-scripts/network-functions | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index f6d2f05b..5ca3abe6 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -9,6 +9,8 @@ export PATH [ -z "$__sed_discard_ignored_files" ] && . /etc/init.d/functions +RESOLVCONF_FLAGFILE=/var/run/resolvconf/enable-updates + get_hwaddr () { if [ -f /sys/class/net/${1}/address ]; then @@ -54,11 +56,6 @@ get_device_by_hwaddr () LANG=C ip -o link | awk -F ': ' -vIGNORECASE=1 '!/link\/ieee802\.11/ && /'"$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" 2>/dev/null | awk -F '"' '/string / { print $2 }' -} - need_config () { local nconfig @@ -121,6 +118,9 @@ source_config () CTC) DEVICETYPE="ctc" ;; + IUCV) + DEVICETYPE="iucv" + ;; GRE | IPIP) DEVICETYPE="tunnel" ;; @@ -147,10 +147,7 @@ source_config () else ISALIAS=no fi - ! is_false $NM_CONTROLLED && is_nm_running && USE_NM=true - if [ -z "$UUID" -a "$USE_NM" = "true" ]; then - UUID=$(get_uuid_by_config $CONFIG) - fi + is_true $NM_CONTROLLED && USE_NM=true } ethtool_set() @@ -171,43 +168,22 @@ ethtool_set() expand_config () { - local i=0 val - for idx in '' {0..255} ; do - ipaddr[$i]=$(eval echo '$'IPADDR$idx) - if [ -z "${ipaddr[$i]}" ]; then - [ "$idx" ] && [ $idx -ge 2 ] && break - continue - fi - prefix[$i]=$(eval echo '$'PREFIX$idx) - netmask[$i]=$(eval echo '$'NETMASK$idx) - broadcast[$i]=$(eval echo '$'BROADCAST$idx) - - if [ "${prefix[$i]}x" != "x" ]; then - val=$(/bin/ipcalc --netmask "${ipaddr[$i]}/${prefix[$i]}") - netmask[$i]=${val##NETMASK=} - fi - - if [ "${netmask[$i]}x" = "x" ]; then - val=$(/bin/ipcalc --netmask "${ipaddr[$i]}") - netmask[$i]=${val##NETMASK=} - fi + if [ -z "${NETMASK}" ]; then + eval $(/bin/ipcalc --netmask ${IPADDR}) + fi - if [ "${prefix[$i]}x" = "x" ]; then - val=$(/bin/ipcalc --prefix ${ipaddr[$i]} ${netmask[$i]}) - prefix[$i]=${val##PREFIX=} - fi + if [ -z "${PREFIX}" ]; then + eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK}) + fi - if [ "${broadcast[$i]}x" = "x" ]; then - val=$(/bin/ipcalc --broadcast ${ipaddr[$i]} ${netmask[$i]}) - broadcast[$i]=${val##BROADCAST=} - fi - i=$((i+1)) - done + if [ -z "${BROADCAST}" ]; then + eval $(/bin/ipcalc --broadcast ${IPADDR} ${NETMASK}) + fi [ -n "$DHCP_HOSTNAME" ] && DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*} if [ -z "${NETWORK}" ]; then - eval $(/bin/ipcalc --network ${ipaddr[0]} ${netmask[0]}) + eval $(/bin/ipcalc --network ${IPADDR} ${NETMASK}) fi } @@ -241,17 +217,19 @@ do_netreport () is_nm_running () { - [ "$(LANG=C nmcli -t --fields running nm status 2>/dev/null)" = "running" ] + [ -x /usr/bin/nmcli ] && \ + [ "$(LANG=C LC_ALL=C nmcli -t --fields running nm status 2>/dev/null)" = "running" ] } is_nm_active () { - LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:connected$" + [ -x /usr/bin/nmcli ] && \ + LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:connected$" } is_nm_device_unmanaged () { - LANG=C nmcli -t --fields GENERAL dev list iface "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }' + LANG=C LC_ALL=C nmcli -t --fields GENERAL dev list iface "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }' } # Sets $alias to the device module if $? != 0 @@ -317,20 +295,34 @@ set_hostname () /bin/rm -f $rsctmp fi fi + if [ -d /etc/sysconfig/network-scripts/hostname.d -a -x /usr/bin/run-parts ]; then + /usr/bin/run-parts --arg $1 /etc/sysconfig/network-scripts/hostname.d + fi } check_device_down () { - if LC_ALL=C ip -o link show dev $1 2>/dev/null | grep -q ",UP" ; then + if echo $1 | grep -q ':' ; then + if LC_ALL=C ifconfig -a 2>/dev/null | grep -q $1 ; then + return 1 + else + return 0 + fi + else + if LC_ALL=C ip -o link 2>/dev/null | grep -q "$1[:@].*,UP" ; then return 1 else return 0 fi + fi } check_link_down () { - if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q ",UP" ; then + if [ "${MII_NOT_SUPPORTED}" = yes ]; then + return 1 + fi + if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then ip link set dev $1 up >/dev/null 2>&1 fi timeout=0 @@ -429,23 +421,39 @@ change_resolv_conf () fi; n_args=$(($n_args-1)); done; - elif [ $# -eq 1 ]; then + elif [ $# -eq 1 -a -r "$1" ]; then if [ "x$s" != "x" ]; then s="$s"$(/bin/grep -vF "$s" $1); else s=$(cat $1); fi; + else + return fi; - (echo "$s" > /etc/resolv.conf;) >/dev/null 2>&1; + if [ -e "$RESOLVCONF_FLAGFILE" ]; then + echo "$s" | /sbin/resolvconf -a ${DEVICE} + else + (echo "$s" > /etc/resolv.conf;) >/dev/null 2>&1; + fi r=$? if [ $r -eq 0 ]; then [ -x /sbin/restorecon ] && /sbin/restorecon /etc/resolv.conf >/dev/null 2>&1 # reset the correct context /usr/bin/logger -p local7.notice -t "NET" -i "$0 : updated /etc/resolv.conf"; - [ -e /var/lock/subsys/nscd ] && /usr/sbin/nscd -i hosts; # invalidate cache + [ -e /var/lock/subsys/nscd ] && [ ! -e "$RESOLVCONF_FLAGFILE" ] && /usr/sbin/nscd -i hosts; # invalidate cache fi; return $r; } +clear_resolv_conf () +{ + if [ -e "$RESOLVCONF_FLAGFILE" ]; then + /sbin/resolvconf -d ${DEVICE} + elif [ -f /etc/resolv.conf.save ]; then + change_resolv_conf /etc/resolv.conf.save + rm -f /etc/resolv.conf.save + fi +} + # Logging function # # Usage: net_log <message> <err|warning|info> <optional file/function name> |