import corrected __group from nico/nico
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
21aacd44b4
commit
18e433dd85
1 changed files with 22 additions and 23 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -23,16 +24,6 @@
|
||||||
|
|
||||||
name="$__object_id"
|
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() {
|
get_current_value() {
|
||||||
local key="$1"
|
local key="$1"
|
||||||
local index
|
local index
|
||||||
|
@ -46,21 +37,29 @@ get_current_value() {
|
||||||
cut -d':' -f $index "$__object/explorer/group"
|
cut -d':' -f $index "$__object/explorer/group"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
set -- "$@"
|
set -- "$@"
|
||||||
cd "$__object/parameter"
|
cd "$__object/parameter"
|
||||||
for property in $(ls .); do
|
|
||||||
current_value=$(get_current_value "$property")
|
if grep -q "^$name" "$__object/explorer/group"; then
|
||||||
new_value="$(cat "$property")"
|
# group exists, only change changed values
|
||||||
if [ "$new_value" != "$current_value" ]; then
|
for property in $(ls .); do
|
||||||
# Shedule changed properties for update
|
current_value=$(get_current_value "$property")
|
||||||
set -- "$@" "--$property" \"$new_value\"
|
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
|
fi
|
||||||
done
|
else
|
||||||
|
for property in $(ls .); do
|
||||||
|
new_value="$(cat "$property")"
|
||||||
|
set -- "$@" "--$property" \"$new_value\"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo groupadd "$@" "$name"
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
# Update changed properties
|
|
||||||
echo $command $@ $name
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue