X-Git-Url: http://git.grml.org/?a=blobdiff_plain;ds=sidebyside;f=sh-lib;h=4d858a9f730ce4bd2db8343b3a9879bea317d360;hb=e87c25a435dccc3ef23453ae9ad096c0fc6b2686;hp=2183b56bd00d18de2642a91c081ce3d302d43182;hpb=4339255e265f34a956fabf7e53e73e3ff92376bd;p=grml-shlib.git diff --git a/sh-lib b/sh-lib index 2183b56..4d858a9 100644 --- a/sh-lib +++ b/sh-lib @@ -428,6 +428,28 @@ function netValidIp return $ret_ } +function netGetIfaces +{ + local error_function_=${1:-"eprint"} # function to call on error + local message_="$2" # user supplied error message + local if_='' + local ret_='' + + #ip a|grep 'inet ' |awk '$NF !~ /lo/{print $NF}' + if_="`ip a|grep 'inet ' |awk '{print $NF}'`" + ret_=$? + if [ -z "$if_" ]; then + if [ -z "$message_" ]; then + "$error_function_" "no interfaces found" $ret_ + else + "$error_function_" "$message_" $ret_ + fi + return 1 + fi + dprint "interfaces found" $ret_ + echo "$if_" +} + # FIXME function netGetDefaultGateway {