From 5212d0a596d67bbd2f5effdd3686c123f778078f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 21 Feb 2010 21:21:48 +0200 Subject: Drop some unnecessary command invocations. --- sysconfig/network-scripts/network-functions | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 562fe7cb..0d2528ee 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -51,7 +51,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 }' } get_uuid_by_config () @@ -207,9 +207,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 -- cgit v1.2.1 From bec37b082a490e101799810fe210aa273ad26de3 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 10 Mar 2011 15:45:33 -0500 Subject: Fix check for unmanaged devices so it does the right thing with devices NM doesn't know about at all. (#670154) It was returning nonexistent devices, or devies NM knew nothing about (bridges), as being managed. --- sysconfig/network-scripts/network-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 0d2528ee..9a47449b 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -230,7 +230,7 @@ is_nm_active () is_nm_device_unmanaged () { - LANG=C nmcli -t --fields device,state dev status 2>/dev/null | grep -q "^${1}: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; }' } # Sets $alias to the device module if $? != 0 -- cgit v1.2.1 From ac1bb973ece7e34f2f9a1606f4b9559e48b2e131 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 25 Mar 2011 15:57:14 -0400 Subject: Add a net_log() function. (#507515, #689525) --- sysconfig/network-scripts/network-functions | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 9a47449b..ed318b0e 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -424,3 +424,26 @@ change_resolv_conf () fi; return $r; } + +# Logging function +# +# Usage: net_log +# +# Default level is 'info'. + +net_log() { + local message="$1" + local level="$2" + local name="$3" + + [ -z "$message" ] && return 1 + [ -z "$level" ] && level=info + [ -z "$name" ] && name=$0 + + echo $message + + if [ -x /usr/bin/logger ]; then + /usr/bin/logger -p daemon.$level -t "$name" "$message" + fi + return 0 +} -- cgit v1.2.1 From 579c34c464ff22339c76bfbf51ce122a8961c0fc Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 25 Mar 2011 15:58:16 -0400 Subject: Make net_log()'s output similar to that of the ipv6 logger. This will cause output strings to change, of course, so it's not really appropriate for earlier releases. --- sysconfig/network-scripts/network-functions | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index ed318b0e..14d13fee 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -440,7 +440,22 @@ net_log() { [ -z "$level" ] && level=info [ -z "$name" ] && name=$0 - echo $message + 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" -- cgit v1.2.1 From 0d4c67a520b64f029d094e9a3d10ec179683c033 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 25 Mar 2011 16:08:45 -0400 Subject: Switch the default logging value to error. It's what's used the most. --- sysconfig/network-scripts/network-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 14d13fee..8d92d081 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -429,7 +429,7 @@ change_resolv_conf () # # Usage: net_log # -# Default level is 'info'. +# Default level is 'err'. net_log() { local message="$1" @@ -437,7 +437,7 @@ net_log() { local name="$3" [ -z "$message" ] && return 1 - [ -z "$level" ] && level=info + [ -z "$level" ] && level=err [ -z "$name" ] && name=$0 case $level in -- cgit v1.2.1 From 77977daabdb09b5dac49e6f5b733527f60cafe6a Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 12 Apr 2011 11:02:34 -0400 Subject: Fix index handling for expanded configs --- sysconfig/network-scripts/network-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 8d92d081..6224f0c9 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -161,7 +161,7 @@ expand_config () for idx in '' {0..255} ; do ipaddr[$i]=$(eval echo '$'IPADDR$idx) if [ -z "${ipaddr[$i]}" ]; then - [ "$idx" ] && [ $idx -gt 2 ] && break + [ "$idx" ] && [ $idx -ge 2 ] && break continue fi prefix[$i]=$(eval echo '$'PREFIX$idx) -- cgit v1.2.1 From 1019b73ba59dd0b842550eb79aef7c4ae8d1dce2 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 18 May 2011 12:47:06 -0400 Subject: Override NETMASK from PREFIX where specified (#705367, ) --- sysconfig/network-scripts/network-functions | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 6224f0c9..5815eaa9 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -168,6 +168,11 @@ expand_config () 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=} -- cgit v1.2.1 From 60ddb21fcdfb0594a35978aa0b04af4527c46d6e Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 31 May 2011 17:35:33 -0400 Subject: Ensure DHCP_HOSTNAME is a short hostname, seed it from HOSTNAME if needed. (#697877) --- sysconfig/network-scripts/network-functions | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 5815eaa9..2d3263a2 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -190,6 +190,8 @@ expand_config () i=$((i+1)) done + [ -n "$DHCP_HOSTNAME" ] && DHCP_HOSTNAME=${DHCP_HOSTNAME%%.*} + if [ -z "${NETWORK}" ]; then eval $(/bin/ipcalc --network ${ipaddr[0]} ${netmask[0]}) fi -- cgit v1.2.1 From 982b6ebfe2cdb1175bc8486135d33b897ad3d6ef Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 28 Jun 2011 14:40:13 -0400 Subject: Allow non-'-s' options in ETHTOOL_OPTS, and allow multiple option types. (#692410, #693583) --- sysconfig/network-scripts/network-functions | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sysconfig/network-scripts/network-functions') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 2d3263a2..f6d2f05b 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -153,7 +153,21 @@ source_config () fi } - +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 () { -- cgit v1.2.1