Add default variable to avoid unbound variable

Co-authored-by: Jeremy Denoun <jeremy.denoun@iguanesolutions.com>
This commit is contained in:
jeremydenoun 2021-01-22 10:02:44 +01:00 committed by GitHub
parent 0edb837f80
commit dce926a536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -295,14 +295,22 @@ is_service_enabled() {
is_kernel_option_enabled() {
local KERNEL_OPTION="$1"
local MODULE_NAME=""
local RESULT=""
if [ $# -ge 2 ]; then
MODULE_NAME="$2"
fi
if $SUDO_CMD [ -r "/proc/config.gz" ]; then
RESULT=$($SUDO_CMD zgrep "^$KERNEL_OPTION=" /proc/config.gz) || :
elif $SUDO_CMD [ -r "/boot/config-$(uname -r)" ]; then
RESULT=$($SUDO_CMD grep "^$KERNEL_OPTION=" "/boot/config-$(uname -r)") || :
else
debug "No information about kernel found, you're probably in a container"
FNRET=127
return
fi
ANSWER=$(cut -d = -f 2 <<<"$RESULT")
if [ "x$ANSWER" = "xy" ]; then
debug "Kernel option $KERNEL_OPTION enabled"