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-functions63
1 files changed, 58 insertions, 5 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 37e088a0..5ca3abe6 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -53,7 +53,7 @@ get_config_by_name ()
get_device_by_hwaddr ()
{
- LANG=C ip -o link | grep -v link/ieee802.11 | awk -F ': ' -vIGNORECASE=1 "/$1/ { print \$2 }"
+ LANG=C ip -o link | awk -F ': ' -vIGNORECASE=1 '!/link\/ieee802\.11/ && /'"$1"'/ { print $2 }'
}
need_config ()
@@ -150,7 +150,21 @@ source_config ()
is_true $NM_CONTROLLED && USE_NM=true
}
-
+ethtool_set()
+{
+ oldifs=$IFS;
+ IFS=';';
+ for opts in $ETHTOOL_OPTS ; do
+ IFS=$oldifs;
+ if [[ "${opts}" =~ [[:space:]]*- ]]; then
+ /sbin/ethtool $opts
+ else
+ /sbin/ethtool -s ${REALDEVICE} $opts
+ fi
+ IFS=';';
+ done
+ IFS=$oldifs;
+}
expand_config ()
{
@@ -166,6 +180,8 @@ expand_config ()
eval $(/bin/ipcalc --broadcast ${IPADDR} ${NETMASK})
fi
+ [ -n "$DHCP_HOSTNAME" ] && DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*}
+
if [ -z "${NETWORK}" ]; then
eval $(/bin/ipcalc --network ${IPADDR} ${NETMASK})
fi
@@ -188,9 +204,8 @@ do_netreport ()
( cd /var/run/netreport || exit
for i in * ; do
if [ -f $i ]; then
- OWNER=$(ls -l $i | awk '{ print $3 }')
-
if [ "$(id -u)" = "0" ]; then
+ OWNER=$(stat -c %U $i)
su -s /bin/bash $OWNER -c "kill -SIGIO $i >/dev/null 2>&1 || rm -f $i >/dev/null 2>&1" > /dev/null 2>&1
else
kill -SIGIO $i >/dev/null 2>&1 || rm -f $i >/dev/null 2>&1
@@ -214,7 +229,7 @@ is_nm_active ()
is_nm_device_unmanaged ()
{
- LANG=C LC_ALL=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}:unmanaged$"
+ 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
@@ -438,3 +453,41 @@ clear_resolv_conf ()
rm -f /etc/resolv.conf.save
fi
}
+
+# Logging function
+#
+# Usage: net_log <message> <err|warning|info> <optional file/function name>
+#
+# Default level is 'err'.
+
+net_log() {
+ local message="$1"
+ local level="$2"
+ local name="$3"
+
+ [ -z "$message" ] && return 1
+ [ -z "$level" ] && level=err
+ [ -z "$name" ] && name=$0
+
+ case $level in
+ 'debug')
+ local txt_level=$"DEBUG "
+ ;;
+ 'err')
+ local txt_level=$"ERROR "
+ ;;
+ 'warning')
+ local txt_level=$"WARN "
+ ;;
+ 'info')
+ local txt_level=$"INFO "
+ ;;
+ esac
+
+ echo "$txt_level: [$name] $message"
+
+ if [ -x /usr/bin/logger ]; then
+ /usr/bin/logger -p daemon.$level -t "$name" "$message"
+ fi
+ return 0
+}