From d6f84d1ef0069c3663f56864626daed5d43370f8 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Thu, 19 Dec 2013 13:54:16 +0100 Subject: [PATCH] __start_on_boot incl. gentoo support --- cdist/conf/type/__start_on_boot/explorer/state | 8 ++++++-- cdist/conf/type/__start_on_boot/gencode-remote | 16 ++++++++-------- cdist/conf/type/__start_on_boot/man.text | 4 +++- .../parameter/default/target_runlevel | 1 + .../conf/type/__start_on_boot/parameter/optional | 1 + 5 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 cdist/conf/type/__start_on_boot/parameter/default/target_runlevel diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index 4e0c82c2..62f86332 100755 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -1,6 +1,7 @@ #!/bin/sh # # 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -23,9 +24,9 @@ os=$("$__explorer/os") runlevel=$("$__explorer/runlevel") +target_runlevel="$(cat "$__object/parameter/target_runlevel")" name="$__object_id" - case "$os" in archlinux) state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \ @@ -42,7 +43,10 @@ case "$os" in state=$(chkconfig --level "$runlevel" "$name" || echo absent) [ "$state" ] || state="present" ;; - + gentoo) + state="present" + [ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent" + ;; *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index a8abebbc..61b2b9fe 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -21,6 +22,7 @@ state_should="$(cat "$__object/parameter/state")" state_is=$(cat "$__object/explorer/state") +target_runlevel="$(cat "$__object/parameter/target_runlevel")" # Short circuit if nothing is to be done [ "$state_should" = "$state_is" ] && exit 0 @@ -38,10 +40,9 @@ case "$state_should" in echo "update-rc.d \"$name\" defaults >/dev/null" ;; -# FIXME: Disabled until the explorer is checked -# gentoo) -# echo rc-update add \"$name\" default -# ;; + gentoo) + echo rc-update add \"$name\" \"$target_runlevel\" + ;; amazon|centos|fedora|owl|redhat|suse) echo chkconfig \"$name\" on @@ -70,10 +71,9 @@ case "$state_should" in echo update-rc.d -f \"$name\" remove ;; -# FIXME: Disabled until the explorer is checked -# gentoo) -# echo rc-update del \"$name\" -# ;; + gentoo) + echo rc-update del \"$name\" \"$target_runlevel\" + ;; centos|fedora|owl|redhat|suse) echo chkconfig \"$name\" off diff --git a/cdist/conf/type/__start_on_boot/man.text b/cdist/conf/type/__start_on_boot/man.text index 6d804884..dfada6d8 100644 --- a/cdist/conf/type/__start_on_boot/man.text +++ b/cdist/conf/type/__start_on_boot/man.text @@ -14,7 +14,7 @@ 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 (i.e. gentoo and *bsd are not implemented). +supported (i.e. *bsd are not implemented). REQUIRED PARAMETERS @@ -25,6 +25,8 @@ 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). EXAMPLES diff --git a/cdist/conf/type/__start_on_boot/parameter/default/target_runlevel b/cdist/conf/type/__start_on_boot/parameter/default/target_runlevel new file mode 100644 index 00000000..4ad96d51 --- /dev/null +++ b/cdist/conf/type/__start_on_boot/parameter/default/target_runlevel @@ -0,0 +1 @@ +default diff --git a/cdist/conf/type/__start_on_boot/parameter/optional b/cdist/conf/type/__start_on_boot/parameter/optional index ff72b5c7..91685caf 100644 --- a/cdist/conf/type/__start_on_boot/parameter/optional +++ b/cdist/conf/type/__start_on_boot/parameter/optional @@ -1 +1,2 @@ state +target_runlevel