Add groups to users properly

This commit is contained in:
Manuel Thalmann 2024-09-12 21:47:50 +02:00
parent dc9f21805e
commit 698d706aa0

View file

@ -5,10 +5,11 @@ set -l users (getUsers)
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
function getUserConfig -S -a config
function getUserConfig -V name -a config
getConfig "valhalla.users.$name.$config" $argv[2..]
end
set -l groups (getUserConfig groups --apply 'builtins.concatStringsSep ","');
set -l displayName (getUserConfig displayName --json)
set -l shell (getUserConfig displayName --json)
@ -17,8 +18,12 @@ for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
echo "--comment"
echo "$displayName" | jq --raw-output
end
) --groups (getUserConfig groups --apply 'builtins.concatStringsSep ","') \
"$name"
) (
if [ -n "$groups" ]
echo "--groups"
echo "$groups"
end
) "$name"
if echo "$shell" | jq --exit-status > /dev/null
sudo chsh "$name" --shell "$shell"