forked from ungleich-public/cdist
		
	__start_on_boot incl. gentoo support
This commit is contained in:
		
					parent
					
						
							
								7d46156fd6
							
						
					
				
			
			
				commit
				
					
						d6f84d1ef0
					
				
			
		
					 5 changed files with 19 additions and 11 deletions
				
			
		| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
 | 
				
			||||||
 | 
					# 2013 Daniel Heule (hda at sfs.biz)
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# This file is part of cdist.
 | 
					# This file is part of cdist.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
| 
						 | 
					@ -23,9 +24,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
os=$("$__explorer/os")
 | 
					os=$("$__explorer/os")
 | 
				
			||||||
runlevel=$("$__explorer/runlevel")
 | 
					runlevel=$("$__explorer/runlevel")
 | 
				
			||||||
 | 
					target_runlevel="$(cat "$__object/parameter/target_runlevel")"
 | 
				
			||||||
name="$__object_id"
 | 
					name="$__object_id"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
case "$os" in
 | 
					case "$os" in
 | 
				
			||||||
    archlinux)
 | 
					    archlinux)
 | 
				
			||||||
        state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \
 | 
					        state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \
 | 
				
			||||||
| 
						 | 
					@ -42,7 +43,10 @@ case "$os" in
 | 
				
			||||||
        state=$(chkconfig --level "$runlevel" "$name" || echo absent)
 | 
					        state=$(chkconfig --level "$runlevel" "$name" || echo absent)
 | 
				
			||||||
        [ "$state" ] || state="present"
 | 
					        [ "$state" ] || state="present"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
 | 
					    gentoo)
 | 
				
			||||||
 | 
					        state="present"
 | 
				
			||||||
 | 
					        [ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent"
 | 
				
			||||||
 | 
					    ;;
 | 
				
			||||||
    *)
 | 
					    *)
 | 
				
			||||||
       echo "Unsupported os: $os" >&2
 | 
					       echo "Unsupported os: $os" >&2
 | 
				
			||||||
       exit 1
 | 
					       exit 1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/sh
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
 | 
					# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
 | 
				
			||||||
 | 
					# 2013 Daniel Heule (hda at sfs.biz)
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# This file is part of cdist.
 | 
					# This file is part of cdist.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
| 
						 | 
					@ -21,6 +22,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
state_should="$(cat "$__object/parameter/state")"
 | 
					state_should="$(cat "$__object/parameter/state")"
 | 
				
			||||||
state_is=$(cat "$__object/explorer/state")
 | 
					state_is=$(cat "$__object/explorer/state")
 | 
				
			||||||
 | 
					target_runlevel="$(cat "$__object/parameter/target_runlevel")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Short circuit if nothing is to be done
 | 
					# Short circuit if nothing is to be done
 | 
				
			||||||
[ "$state_should" = "$state_is" ] && exit 0
 | 
					[ "$state_should" = "$state_is" ] && exit 0
 | 
				
			||||||
| 
						 | 
					@ -38,10 +40,9 @@ case "$state_should" in
 | 
				
			||||||
                echo "update-rc.d \"$name\" defaults >/dev/null"
 | 
					                echo "update-rc.d \"$name\" defaults >/dev/null"
 | 
				
			||||||
            ;;
 | 
					            ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#           FIXME: Disabled until the explorer is checked
 | 
					            gentoo)
 | 
				
			||||||
#            gentoo)
 | 
					                echo rc-update add \"$name\" \"$target_runlevel\"
 | 
				
			||||||
#                echo rc-update add \"$name\" default
 | 
					            ;;
 | 
				
			||||||
#            ;;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            amazon|centos|fedora|owl|redhat|suse)
 | 
					            amazon|centos|fedora|owl|redhat|suse)
 | 
				
			||||||
                echo chkconfig \"$name\" on
 | 
					                echo chkconfig \"$name\" on
 | 
				
			||||||
| 
						 | 
					@ -70,10 +71,9 @@ case "$state_should" in
 | 
				
			||||||
                echo update-rc.d -f \"$name\" remove
 | 
					                echo update-rc.d -f \"$name\" remove
 | 
				
			||||||
            ;;
 | 
					            ;;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# FIXME: Disabled until the explorer is checked
 | 
					            gentoo)
 | 
				
			||||||
#            gentoo)
 | 
					                echo rc-update del \"$name\"  \"$target_runlevel\"
 | 
				
			||||||
#                echo rc-update del \"$name\"
 | 
					            ;;
 | 
				
			||||||
#            ;;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            centos|fedora|owl|redhat|suse)
 | 
					            centos|fedora|owl|redhat|suse)
 | 
				
			||||||
                echo chkconfig \"$name\" off
 | 
					                echo chkconfig \"$name\" off
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ This cdist type allows you to enable or disable stuff to be started
 | 
				
			||||||
at boot of your operating system.
 | 
					at boot of your operating system.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Warning: This type has not been tested intensively and is not fully
 | 
					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
 | 
					REQUIRED PARAMETERS
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,8 @@ OPTIONAL PARAMETERS
 | 
				
			||||||
-------------------
 | 
					-------------------
 | 
				
			||||||
state::
 | 
					state::
 | 
				
			||||||
    Either "present" or "absent", defaults to "present"
 | 
					    Either "present" or "absent", defaults to "present"
 | 
				
			||||||
 | 
					target_runlevel::
 | 
				
			||||||
 | 
					    Runlevel which should be modified, defaults to "default" (only used on gentoo systems).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXAMPLES
 | 
					EXAMPLES
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					default
 | 
				
			||||||
| 
						 | 
					@ -1 +1,2 @@
 | 
				
			||||||
state
 | 
					state
 | 
				
			||||||
 | 
					target_runlevel
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue