fix for older linuxes where gpasswd doesn't have the relevant options ...

This commit is contained in:
Daniel Heule 2015-05-08 14:08:53 +02:00
parent 00d5524af9
commit 62bd5898aa

View file

@ -21,6 +21,20 @@
user="$(cat "$__object/parameter/user" 2>/dev/null || echo "$__object_id")" user="$(cat "$__object/parameter/user" 2>/dev/null || echo "$__object_id")"
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
os_version="$(cat "$__global/explorer/os_version")"
case "$os_version" in
SUSE\ Linux\ Enterprise\ Server\ 11*VERSION\ =\ 11*)
old=yes
addparam="-A"
delparam="-R"
;;
*)
old=no
addparam="-a"
delparam="-d"
;;
esac
mkdir "$__object/files" mkdir "$__object/files"
# file has to be sorted for comparison with `comm` # file has to be sorted for comparison with `comm`
sort "$__object/parameter/group" > "$__object/files/group.sorted" sort "$__object/parameter/group" > "$__object/files/group.sorted"
@ -28,11 +42,11 @@ sort "$__object/parameter/group" > "$__object/files/group.sorted"
case "$state_should" in case "$state_should" in
present) present)
changed_groups="$(comm -13 "$__object/explorer/group" "$__object/files/group.sorted")" changed_groups="$(comm -13 "$__object/explorer/group" "$__object/files/group.sorted")"
action="-a" action="$addparam"
;; ;;
absent) absent)
changed_groups="$(comm -12 "$__object/explorer/group" "$__object/files/group.sorted")" changed_groups="$(comm -12 "$__object/explorer/group" "$__object/files/group.sorted")"
action="-d" action="$delparam"
;; ;;
esac esac
@ -42,5 +56,9 @@ if [ -z "$changed_groups" ]; then
fi fi
for group in $changed_groups; do for group in $changed_groups; do
if [ "$old" = "no" ]; then
echo "gpasswd $action \"$user\" \"$group\"" echo "gpasswd $action \"$user\" \"$group\""
else
echo "usermod $action \"$group\" \"$user\""
fi
done done