__start_on_boot incl. gentoo support

This commit is contained in:
Daniel Heule 2013-12-19 13:54:16 +01:00
parent 7d46156fd6
commit d6f84d1ef0
5 changed files with 19 additions and 11 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -0,0 +1 @@
default

View file

@ -1 +1,2 @@
state
target_runlevel