aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r--sysconfig/network-scripts/network-functions48
1 files changed, 41 insertions, 7 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 9715d8d1..3c0205f0 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
@@ -171,7 +173,7 @@ source_config ()
ISALIAS=no
fi
if ! is_false $NM_CONTROLLED && is_nm_running; then
- nmcli con load "/etc/sysconfig/network-scripts/$CONFIG"
+ nmcli con load "/etc/sysconfig/network-scripts/$CONFIG" 2>/dev/null
UUID=$(get_uuid_by_config $CONFIG)
[ -n "$UUID" ] && _use_nm=true
fi
@@ -273,22 +275,32 @@ do_netreport ()
is_nm_running ()
{
- [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]
+ [ -x /usr/bin/nmcli ] && \
+ [ "$(LANG=C LC_ALL=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]
+}
+
+is_nm_device_unavailable ()
+{
+ [ -x /usr/bin/nmcli ] && \
+ LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:unavailable$"
}
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_handling ()
{
+ [ -x /usr/bin/nmcli ] && \
LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
}
is_nm_device_unmanaged ()
{
- LANG=C nmcli -t --fields GENERAL dev show "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }'
+ [ -x /usr/bin/nmcli ] && \
+ LANG=C LC_ALL=C nmcli -t --fields GENERAL dev show "${1}" 2>/dev/null | awk -F ':' '/GENERAL.STATE/ { if ($2 == "unmanaged") exit 0 ; else exit 1; }'
}
# Sets $alias to the device module if $? != 0
@@ -372,6 +384,9 @@ 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 ()
@@ -386,7 +401,10 @@ check_device_down ()
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
@@ -561,14 +579,20 @@ 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"$'\n'$(/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
@@ -578,6 +602,16 @@ change_resolv_conf ()
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>