aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rwxr-xr-x[-rw-r--r--]sysconfig/network-scripts/network-functions45
1 files changed, 39 insertions, 6 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 9d6f9366..d2a2de85 100644..100755
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -13,6 +13,8 @@ HOSTNAME="$(hostname)"
[ -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
@@ -306,19 +308,28 @@ is_nm_running ()
string:"org.freedesktop.NetworkManager" >/dev/null 2>&1
}
+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 ()
{
- LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
+ [ -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
@@ -456,6 +467,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 ()
@@ -470,7 +484,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
@@ -646,14 +663,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
+ if [ -e "$RESOLVCONF_FLAGFILE" ]; then
+ echo "$s" | /sbin/resolvconf -a ${DEVICE}
+ else
+ (echo "$s" > /etc/resolv.conf) >/dev/null 2>&1;
fi
- (echo "$s" > /etc/resolv.conf) >/dev/null 2>&1;
r=$?
if [ $r -eq 0 ]; then
[ -x /sbin/restorecon ] && /sbin/restorecon /etc/resolv.conf >/dev/null 2>&1 # reset the correct context
@@ -663,6 +686,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>