Shorten option for both useradd and usermod.

We need to shorten options for both usermod and useradd since on some
systems (such as *BSD, Darwin) those commands do not handle GNU style long
options.

Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
This commit is contained in:
Sébastien Gross 2012-06-18 17:54:19 +02:00
parent f23e869277
commit 2a20b01a3f

View file

@ -24,6 +24,22 @@
name="$__object_id" name="$__object_id"
# We need to shorten options for both usermod and useradd since on some
# systems (such as *BSD, Darwin) those commands do not handle GNU style long
# options.
shorten_property() {
RET=
case "$1" in
comment) RET="-c";;
home) RET="-d";;
gid) RET="-g";;
groups) RET="-G";;
password) RET="-p";;
shell) RET="-s";;
uid) RET="-u";;
esac
}
cd "$__object/parameter" cd "$__object/parameter"
if grep -q "^${name}:" "$__object/explorer/passwd"; then if grep -q "^${name}:" "$__object/explorer/passwd"; then
for property in $(ls .); do for property in $(ls .); do
@ -67,7 +83,8 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
fi fi
if [ "$new_value" != "$current_value" ]; then if [ "$new_value" != "$current_value" ]; then
set -- "$@" "--$property" \'$new_value\' shorten_property $property
set -- "$@" "$RET" \'$new_value\'
fi fi
done done
@ -79,7 +96,8 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
else else
for property in $(ls .); do for property in $(ls .); do
new_value="$(cat "$property")" new_value="$(cat "$property")"
set -- "$@" "--$property" \'$new_value\' shorten_property $property
set -- "$@" "$RET" \'$new_value\'
done done
echo useradd "$@" "$name" echo useradd "$@" "$name"