From f54ced4a08e9cbe72d75e2ae52b5e503dcc0711e Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 12 Sep 2024 21:47:50 +0200 Subject: [PATCH] Add groups to users properly --- scripts/Common/OS/users.fish | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/Common/OS/users.fish b/scripts/Common/OS/users.fish index d6f631b4..88533692 100755 --- a/scripts/Common/OS/users.fish +++ b/scripts/Common/OS/users.fish @@ -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 defaultShell --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 (which (echo "$shell" | jq --raw-output))