Add users from configuration
This commit is contained in:
parent
e15a64816b
commit
e62637b3be
3 changed files with 32 additions and 5 deletions
scripts/Common/OS
|
@ -39,5 +39,10 @@ else
|
|||
runHook installOS || true
|
||||
runHook installSoftware || true
|
||||
runHook initializeConfig || true
|
||||
|
||||
runHook addUsers || begin
|
||||
source "$dir/users.fish"
|
||||
end
|
||||
|
||||
runHook postInstall || true
|
||||
end
|
||||
|
|
27
scripts/Common/OS/users.fish
Normal file
27
scripts/Common/OS/users.fish
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/env fish
|
||||
set -l dir (status dirname)
|
||||
source "$dir/../Scripts/config.fish"
|
||||
set -l users (getConfig valhalla.users --apply "builtins.attrNames" --json)
|
||||
|
||||
|
||||
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
|
||||
function getUserConfig -S -a config
|
||||
getConfig "valhalla.users.$name.$config" $argv[2..]
|
||||
end
|
||||
|
||||
set -l displayName (getUserConfig displayName --json)
|
||||
|
||||
useradd --create-home (
|
||||
if echo "$displayName" | jq --exit-status > /dev/null
|
||||
echo "--comment"
|
||||
echo "$displayName" | jq --raw-output
|
||||
end
|
||||
) --groups (getUserConfig groups --apply 'builtins.concatStringsSep ","') \
|
||||
"$name"
|
||||
|
||||
echo "Please Choose a New Password for User \`$name\`"
|
||||
|
||||
while ! passwd "$name"
|
||||
echo "An error occurred! Please try again."
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue