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

chore: update script related to systemctl / service

- configure_systemd-timesync.sh:        use "is_service_enabled" instead of calling systemctl
- disable_automounting.sh:              use "manage_service" instead of "update-rc.d"
- enable_auditd.sh:                     use "manage_service" instead of "update-rc.d"
- enable_cron.sh:                       use "manage_service" instead of "update-rc.d"
- enable_syslog-ng.sh:                  use "manage_service" instead of "update-rc.d"
This commit is contained in:
Damien Cavagnini
2025-07-11 14:20:27 +02:00
committed by damien cavagnini
parent 4a2e61a2fb
commit b9ded91724

View File

@@ -593,8 +593,6 @@ is_pkg_installed() {
is_pkg_a_dependency() {
# check if package is needed by another installed package
local PKG_NAME=$1
# ex: 'dnsmasq' is going to install 'dnsmasq-base'
# so we don't care about 'dnsmasq-base', we want to know about others packages
shift
local known_deps="$*"
@@ -672,5 +670,4 @@ manage_service() {
fi
systemctl "$action" "$service" >/dev/null 2>&1
}