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
This commit is contained in:
Damien Cavagnini
2025-07-10 10:22:06 +02:00
committed by damien cavagnini
parent 4a2e61a2fb
commit 74346b222f

View File

@@ -606,7 +606,6 @@ is_pkg_a_dependency() {
# need a 'if' even for a single sentence, due to 'set -u' # need a 'if' even for a single sentence, due to 'set -u'
PKG_DEPENDENCIES="$PKG_DEPENDENCIES $pkg_dep_name" PKG_DEPENDENCIES="$PKG_DEPENDENCIES $pkg_dep_name"
fi fi
done <<<"$(apt-cache rdepends "$PKG_NAME" | sed -e '1,2d' -e 's/^\ *//g' -e 's/^|//g' | sort -u)" done <<<"$(apt-cache rdepends "$PKG_NAME" | sed -e '1,2d' -e 's/^\ *//g' -e 's/^|//g' | sort -u)"
if [ -n "$PKG_DEPENDENCIES" ]; then if [ -n "$PKG_DEPENDENCIES" ]; then