From 42e3c18d02823a47423ac194ef884a57fd741aa2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 18 Jan 2012 15:54:32 +0100 Subject: [PATCH] +update of __start_on_boot Signed-off-by: Nico Schottelius --- conf/type/__start_on_boot/explorer/state | 2 +- conf/type/__start_on_boot/gencode-remote | 71 ++++++++++++------------ conf/type/__start_on_boot/man.text | 3 + 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/conf/type/__start_on_boot/explorer/state b/conf/type/__start_on_boot/explorer/state index c68ec2ba..136c1e05 100755 --- a/conf/type/__start_on_boot/explorer/state +++ b/conf/type/__start_on_boot/explorer/state @@ -21,7 +21,7 @@ # Check whether the given name will be started on boot or not # -os=$(cat "$__global/explorer/os") +os=$("$__explorer/os") case "$os" in debian|ubuntu) diff --git a/conf/type/__start_on_boot/gencode-remote b/conf/type/__start_on_boot/gencode-remote index 9e700934..5133810d 100755 --- a/conf/type/__start_on_boot/gencode-remote +++ b/conf/type/__start_on_boot/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,49 +18,48 @@ # along with cdist. If not, see . # # -# __file is a very basic type, which will probably be reused quite often -# -destination="/$__object_id" -state_should="$(cat "$__object/parameter/state")" -exists="$(cat "$__object/explorer/exists")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi + +os=$(cat "$__global/explorer/os") +name="$__object_id" + +# Support runlevels later +#runlevel=$(cat $__global/explorer/runlevel) case "$state_should" in - present) - # No source? Create empty file - if [ ! -f "$__object/parameter/source" ]; then - if [ "$exists" = "no" ]; then - echo touch \"$destination\" - fi - fi + present) + case "$os" in + debian|ubuntu) + echo update-rc.d \"$name\" defaults + ;; - # Mode settings - if [ -f "$__object/parameter/mode" ]; then - echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" - fi + gentoo) + echo rc-update add \"$name\" default + ;; - # Group - if [ -f "$__object/parameter/group" ]; then - echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\" - fi + centos|fedora|owl|redhat) + echo echo chkconfig \"$name\" on + ;; - # Owner - if [ -f "$__object/parameter/owner" ]; then - echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" - fi - ;; + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; + esac + ;; - absent) + absent) - if [ "$exists" = "yes" ]; then - echo rm -f \"$destination\" - fi + ;; - ;; - - *) - echo "Unknown state: $state_should" >&2 - exit 1 - ;; + *) + echo "Unknown state: $state_should" >&2 + exit 1 + ;; esac diff --git a/conf/type/__start_on_boot/man.text b/conf/type/__start_on_boot/man.text index e9691401..eb9dbe7f 100644 --- a/conf/type/__start_on_boot/man.text +++ b/conf/type/__start_on_boot/man.text @@ -23,6 +23,9 @@ OPTIONAL PARAMETERS state:: 'present' or 'absent', defaults to 'present' +runlevel:: + Specify runlevel(s) to affect. Defaults to default or current runlevel. + EXAMPLES --------