X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sh-lib;h=06c66b5412b865f2054b583cdd13bd5b8cf97876;hb=351376b85f7689b56cba6b93bc1fdbc90fea127c;hp=2183b56bd00d18de2642a91c081ce3d302d43182;hpb=4339255e265f34a956fabf7e53e73e3ff92376bd;p=grml-shlib.git diff --git a/sh-lib b/sh-lib index 2183b56..06c66b5 100644 --- a/sh-lib +++ b/sh-lib @@ -51,6 +51,9 @@ function unsetVerbose { VERBOSE_TMP__=$VERBOSE__; VERBOSE__=0; } function restoreVerbose { VERBOSE__=$VERBOSE_TMP__; } function getVerbose { echo "$VERBOSE__"; } +function setDebug { setVerbose "$DPRINT__"; } +function unsetDebug { restoreVerbose; } + function setExitFunction { EXIT_FUNCTION__="$1"; } function resetExitFunction { EXIT_FUNCTION__="_syslog"; } # }}} @@ -428,6 +431,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 { @@ -622,8 +647,16 @@ function _checkBootParam return 1 } _checkBootParam + + +function _setDebugLevel +{ + local debug_="${DEBUG:-0}" + VERBOSE__="$debug_" +} +_checkBootParam # }}} # END OF FILE ################################################################################ -# vim:foldmethod=marker +# vim:foldmethod=marker expandtab shiftwidth=2 tabstop=2