|
|
|
@ -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\" |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
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 $command $@ $name |
|
|
|
|
fi |
|
|
|
|
if [ $# -gt 0 ]; then |
|
|
|
|
# Update changed properties |
|
|
|
|
echo groupmod $@ $name |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
for property in $(ls .); do |
|
|
|
|
new_value="$(cat "$property")" |
|
|
|
|
set -- "$@" "--$property" \"$new_value\" |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
echo groupadd "$@" "$name" |
|
|
|
|
fi |
|
|
|
|