## # retrieve interfaces. I prefer using ip if it is # available, else I fallback to ifconfig... don't know # how to retrieve this information on other systems. # This also exports the environment variables. # gather_interface_info() { [ -z "${NINTERFACES}" ] || return local NO=1 if [ ${IP} ] then gather_if_info_ip else if [ ${IFCONFIG} ] then gather_if_info_ifconfig else ${LOGGER} -p local0.warn 'Found no way to retrieve interface information.' fi fi export NINTERFACES export CLASSES while [ ${NO} -le ${NINTERFACES:=0} ] do export IF${NO}_NAME IF${NO}_MAC IF${NO}_STATE IF${NO}_IPV4 IF${NO}_IPV6 NO=$((NO+1)) done } ## # get the interface information from the ip tool # gather_if_info_ip() { eval $(${IP} -o link | ${AWK} '{ sub(/:/,"",$1); no=$1; sub(/:/,"",$2); name=$2; for (i=3; i