From 1ec2149386beca68792496b600a5cf71f4a36709 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 12 Aug 2020 13:51:22 +0200 Subject: Add warning to warn user when ETHTOOL_OPTS is set and ethtool binary is missing - Olav Vitters --- network-scripts/network-functions | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'network-scripts/network-functions') diff --git a/network-scripts/network-functions b/network-scripts/network-functions index 332115b8..42d01f31 100644 --- a/network-scripts/network-functions +++ b/network-scripts/network-functions @@ -195,25 +195,29 @@ nm_con_load () { array:string:"/etc/sysconfig/network-scripts/${1}" >/dev/null 2>&1 } -ethtool_set() +ethtool_set () { - oldifs=$IFS; - IFS=';'; - if [ -n "${ETHTOOL_DELAY}" ]; then - # Convert microseconds to seconds: - local ETHTOOL_DELAY_SEC=$(convert2sec ${ETHTOOL_DELAY} micro) - sleep ${ETHTOOL_DELAY_SEC} - fi - for opts in $ETHTOOL_OPTS ; do - IFS=$oldifs; - if [[ "${opts}" =~ [[:space:]]*- ]]; then - /sbin/ethtool $opts - else - /sbin/ethtool -s ${REALDEVICE} $opts - fi + if [ -n "${ETHTOOL_OPTS}" ] && [ ! -x /sbin/ethtool ] ; then + net_log "ethtool does not exist or is not executable." warning + else + oldifs=$IFS; IFS=';'; - done - IFS=$oldifs; + if [ -n "${ETHTOOL_DELAY}" ] ; then + # Convert microseconds to seconds: + local ETHTOOL_DELAY_SEC=$(convert2sec ${ETHTOOL_DELAY} micro) + sleep ${ETHTOOL_DELAY_SEC} + fi + 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; + fi } expand_config () -- cgit v1.2.1