From 57aa0e6ef51ce7580c90e48a26ba24aab89a2880 Mon Sep 17 00:00:00 2001 From: Damien Cavagnini Date: Thu, 10 Jul 2025 10:22:06 +0200 Subject: [PATCH] update lib/utils.sh - add 'is_pkg_a_dependency', to ensure a package is not needed by some others before removing it -> will be used in debian 12 CIS by at least the 2.1.5 recommendation - update 'is_service_enabled' to use 'systemd' instead of 'rc.d', as we are now only supporting debian LTS using systemd - add 'is_using_sbin_init' to ensure we can use systemctl, in case of running on non detected container - add 'manage_service' to enable / disable service using systemctl --- lib/utils.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils.sh b/lib/utils.sh index 4ebdd1c..eba0f7d 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -599,11 +599,12 @@ is_pkg_a_dependency() { local known_deps="$*" PKG_DEPENDENCIES="" + # shellcheck disable=2162 while read pkg_dep_name; do is_pkg_installed "$pkg_dep_name" if [ "$FNRET" -eq 0 ] && ! grep -w "$pkg_dep_name" <<<"$known_deps" >/dev/null; then - # need a 'if' even for a single sentence, due to 'set -u' + # need a 'if' even for a single sentence, due to 'set -e' PKG_DEPENDENCIES="$PKG_DEPENDENCIES $pkg_dep_name" fi