From 2a20b01a3f9462daeddd23b71c55cb2cf0a07d95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gross?= Date: Mon, 18 Jun 2012 17:54:19 +0200 Subject: [PATCH] Shorten option for both useradd and usermod. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- conf/type/__user/gencode-remote | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/conf/type/__user/gencode-remote b/conf/type/__user/gencode-remote index 8979c56e..bbf373d4 100755 --- a/conf/type/__user/gencode-remote +++ b/conf/type/__user/gencode-remote @@ -24,6 +24,22 @@ 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" if grep -q "^${name}:" "$__object/explorer/passwd"; then for property in $(ls .); do @@ -67,7 +83,8 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then fi if [ "$new_value" != "$current_value" ]; then - set -- "$@" "--$property" \'$new_value\' + shorten_property $property + set -- "$@" "$RET" \'$new_value\' fi done @@ -79,7 +96,8 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then else for property in $(ls .); do new_value="$(cat "$property")" - set -- "$@" "--$property" \'$new_value\' + shorten_property $property + set -- "$@" "$RET" \'$new_value\' done echo useradd "$@" "$name"