From 850c69bf4977545553d499cf68c724031ac7e6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Fri, 24 May 2024 10:32:46 +0200 Subject: [PATCH] [__start_on_boot] remove legacy logic on OSs that moved to systemd --- .../conf/type/__start_on_boot/explorer/state | 29 ++++--------------- .../conf/type/__start_on_boot/gencode-remote | 26 +++-------------- cdist/conf/type/__start_on_boot/man.rst | 6 ++-- 3 files changed, 11 insertions(+), 50 deletions(-) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index b7a6cf0f..d2400359 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -37,7 +37,7 @@ if [ "$init" = 'systemd' ]; then else case "$os" in - debian|openwrt|devuan) + openwrt|devuan) state="absent" for file in "/etc/rc$runlevel.d/S"??"$name" do @@ -48,33 +48,12 @@ else fi done ;; - ubuntu) - state="absent" - for file in "/etc/rc$runlevel.d/S"??"$name" - do - if [ -f "$file" ] - then - state="present" - break - fi - done - [ -f "/etc/init/${name}.conf" ] && state="present" - ;; - - amazon|scientific|centos|fedora|owl|redhat) + owl) state=$(chkconfig --level "$runlevel" "$name" || echo absent) [ "$state" ] || state="present" ;; - suse) - # check for target if set, usable for boot. services in runlevel B - if [ "$target_runlevel" != 'default' ]; then - runlevel="$target_runlevel" - fi - # suses chkconfig has the same name, but works different ... - state=$(chkconfig --check "$name" "$runlevel" || echo absent) - [ "$state" ] || state="present" - ;; + gentoo|alpine) state="absent" for d in /etc/runlevels/*; do @@ -84,10 +63,12 @@ else fi done ;; + freebsd) state="absent" service -e | grep "/$name$" && state="present" ;; + openbsd) state='absent' # OpenBSD 5.7 and higher diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index c900933f..c9597bb7 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -36,24 +36,10 @@ case "$state_should" in present) if [ "$init" = 'systemd' ]; then # this handles ALL linux distros with systemd - # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions + # e.g. debian, fedora, archlinux, gentoo in some cases, new RHEL and SLES versions echo "systemctl -q enable '$name'" else case "$os" in - debian) - case "$os_version" in - [1-7]*) - echo "update-rc.d '$name' defaults >/dev/null" - ;; - 8*) - echo "systemctl enable '$name'" - ;; - *) - echo "Unsupported version $os_version of $os" >&2 - exit 1 - ;; - esac - ;; devuan) echo "update-rc.d '$name' defaults >/dev/null" ;; @@ -62,7 +48,7 @@ case "$state_should" in echo "rc-update add '$name' '$target_runlevel'" ;; - amazon|scientific|centos|fedora|owl|redhat|suse) + owl) echo "chkconfig '$name' on" ;; @@ -73,10 +59,6 @@ case "$state_should" in echo "'/etc/init.d/$name' enable || [ -f /etc/rc.d/S??'$name' ]" ;; - ubuntu) - echo "update-rc.d '$name' defaults >/dev/null" - ;; - freebsd) : # handled in manifest ;; @@ -102,7 +84,7 @@ case "$state_should" in else case "$os" in - debian|ubuntu|devuan) + devuan) echo "update-rc.d -f '$name' remove" ;; @@ -110,7 +92,7 @@ case "$state_should" in echo "rc-update del '$name' '$target_runlevel'" ;; - centos|fedora|owl|redhat|suse) + owl) echo "chkconfig '$name' off" ;; diff --git a/cdist/conf/type/__start_on_boot/man.rst b/cdist/conf/type/__start_on_boot/man.rst index f8afe94b..a8fbf0a8 100644 --- a/cdist/conf/type/__start_on_boot/man.rst +++ b/cdist/conf/type/__start_on_boot/man.rst @@ -11,10 +11,6 @@ DESCRIPTION This cdist type allows you to enable or disable stuff to be started at boot of your operating system. -Warning: This type has not been tested intensively and is not fully -supported. - - REQUIRED PARAMETERS ------------------- None. @@ -24,6 +20,7 @@ OPTIONAL PARAMETERS ------------------- state Either "present" or "absent", defaults to "present" + target_runlevel Runlevel which should be modified, defaults to "default" (only used on gentoo systems). @@ -51,6 +48,7 @@ SEE ALSO AUTHORS ------- Nico Schottelius +Timothée Floure COPYING