From 18e433dd859644a8d69c07ff2a22e14c2091d963 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 14:24:20 +0200 Subject: [PATCH] import corrected __group from nico/nico Signed-off-by: Nico Schottelius --- conf/type/__group/gencode-remote | 45 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index 527a6079..ac7e0ebb 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -23,16 +24,6 @@ name="$__object_id" -command= -if grep -q "^$name" "$__object/explorer/group"; then - # group exists - command="groupmod" -else - # group does not exist - command="groupadd" -fi - - get_current_value() { local key="$1" local index @@ -46,21 +37,29 @@ get_current_value() { cut -d':' -f $index "$__object/explorer/group" } - set -- "$@" cd "$__object/parameter" -for property in $(ls .); do - current_value=$(get_current_value "$property") - new_value="$(cat "$property")" - if [ "$new_value" != "$current_value" ]; then - # Shedule changed properties for update - set -- "$@" "--$property" \"$new_value\" + +if grep -q "^$name" "$__object/explorer/group"; then + # group exists, only change changed values + for property in $(ls .); do + current_value=$(get_current_value "$property") + new_value="$(cat "$property")" + if [ "$new_value" != "$current_value" ]; then + # Shedule changed properties for update + set -- "$@" "--$property" \"$new_value\" + fi + done + + if [ $# -gt 0 ]; then + # Update changed properties + echo groupmod $@ $name fi -done +else + for property in $(ls .); do + new_value="$(cat "$property")" + set -- "$@" "--$property" \"$new_value\" + done - -if [ $# -gt 0 ]; then - # Update changed properties - echo $command $@ $name + echo groupadd "$@" "$name" fi -