38 lines
1.1 KiB
Fish
Executable file
38 lines
1.1 KiB
Fish
Executable file
#!/bin/env fish
|
|
set -l dir (status dirname)
|
|
source "$dir/../Scripts/config.fish"
|
|
set -l users (getUsers)
|
|
|
|
|
|
for name in (echo "$users" | jq '.[]' --raw-output0 | string split0)
|
|
function getUserConfig -V name -a config
|
|
getConfig "valhalla.linux.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)
|
|
|
|
sudo useradd --create-home (
|
|
if echo "$displayName" | jq --exit-status > /dev/null
|
|
echo "--comment"
|
|
echo "$displayName" | jq --raw-output
|
|
end
|
|
) (
|
|
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))
|
|
end
|
|
|
|
echo "Please Choose a New Password for User `$name`"
|
|
|
|
while ! sudo passwd "$name"
|
|
echo "An error occurred! Please try again."
|
|
end
|
|
end
|