From 6bde0e7c07c4d0ee8cc6f6aa37c49608fe924a5b Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 16 Mar 2018 08:50:36 +0100 Subject: [PATCH] Replace 'ifconfig' calls with 'ip'. --- check_net.sh | 4 ++-- netconfig.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/check_net.sh b/check_net.sh index e1607fa..0ee4573 100755 --- a/check_net.sh +++ b/check_net.sh @@ -194,7 +194,7 @@ declare -A filetime_PID_arr for inet_device in "${online_devices_arr[@]}" ; do if containsElement "$inet_device" "${dsl_devices_arr[@]}" ; then - remote_gw_address=`ifconfig $inet_device 2> /dev/null | grep "inet Adresse" | cut -d":" -f3 | cut -d" " -f1` + remote_gw_address="$(ip addr show $inet_device 2> /dev/null | grep peer | awk '{print$4}' | cut -d "/" -f1)" else remote_gw_address=${static_gw_arr[$inet_device]} fi @@ -263,7 +263,7 @@ while true ; do ## - Is remote a remote gateway for this device knpn? ## - - remote_gw_address=`ifconfig $inet_device 2> /dev/null | grep "inet Adresse" | cut -d":" -f3 | cut -d" " -f1` + remote_gw_address="$(ip addr show $inet_device 2> /dev/null | grep peer | awk '{print$4}' | cut -d "/" -f1)" iface_name="dsl-`echo $inet_device | cut -d '-' -f2`" rt_name="dsl_`echo $inet_device | cut -d '-' -f2`" if [[ -n "$remote_gw_address" ]]; then diff --git a/netconfig.sh b/netconfig.sh index bce0dee..70e378d 100755 --- a/netconfig.sh +++ b/netconfig.sh @@ -308,7 +308,7 @@ while ! $configured && [ $_try_number -lt $max_attempts ] ; do ## - Is the device present and has local Address ? ## - - local_gw_address=`ifconfig $inet_device 2> /dev/null | grep "inet Adresse" | cut -d":" -f2 | cut -d" " -f1` + local_gw_address="$(ip addr show $inet_device 2> /dev/null | grep inet | awk '{print$2}')" if [ -z $local_gw_address ]; then if $LOGGING_CONSOLE ; then echo -e "\n\t[ Error ]: Connection at interface \"$inet_device\" seems to be down !" @@ -350,7 +350,7 @@ while ! $configured && [ $_try_number -lt $max_attempts ] ; do ## - Is the DSL-device known and has remote Address ? ## - if containsElement "$inet_device" "${dsl_devices_arr[@]}" ; then - remote_gw_address=`ifconfig $inet_device 2> /dev/null | grep "inet Adresse" | cut -d":" -f3 | cut -d" " -f1` + remote_gw_address="$(ip addr show $inet_device 2> /dev/null | grep peer | awk '{print$4}' | cut -d "/" -f1)" remote_gw_net="$remote_gw_address/32" else net_address=`sipcalc $inet_device 2> /dev/null | grep -i -e "^network\s*address\s*-" | awk '{print$4}'`