From dce926a536afe70f955361792d4ae513a7980220 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Fri, 22 Jan 2021 10:02:44 +0100 Subject: [PATCH] Add default variable to avoid unbound variable Co-authored-by: Jeremy Denoun --- lib/utils.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/utils.sh b/lib/utils.sh index 8237073..0d0c959 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -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"