__user: only run commands if value has changed

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-03-15 23:11:01 +01:00
parent 42c87edad1
commit 1518bf1935
2 changed files with 25 additions and 4 deletions

View File

@ -1,3 +1,2 @@
- gencode: compair new value with existing one in $__object/explorer/passwd, only change if nessecary
- delete users

View File

@ -33,12 +33,34 @@ else
fi
get_current_value() {
local key="$1"
local index
case "$key" in
uid) index=3;;
gid) index=4;;
comment) index=5;;
home) index=6;;
shell) index=7;;
esac
cut -d':' -f $index "$__object/explorer/passwd"
}
set -- "$@"
cd "$__object/parameter"
for property in $(ls .); do
# TODO: compair new value with existing one in $__object/explorer/passwd, only change if nessecary
set -- "$@" "--$property" "$(cat "$property")"
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
echo $command $@ $name
if [ $# -gt 0 ]; then
# Update changed properties
echo $command $@ $name
fi