Add setup users task

install-scripts
trivernis 2 years ago
parent 622f28dfbc
commit 589584c7c6
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,6 +1,28 @@
let RUN_IN_CHROOT = true;
def create_user [user] {
debug $"Configuring user $($user.name)"
let shell = $"/usr/bin/($user.shell)"
run useradd -m -s $shell -p $user.password $user.name
if $user.sudoer {
debug "user is sudoer"
run usermod -aG wheel $user.name
}
touch "/var/lib/AccountsService/users/($user.name)"
"[User]\nsession=onyx" | save -a "/var/lib/AccountsService/users/($user.name)"
info $"Created user ($user.name)"
}
# Applies all system changes of `setup-users`
def main [cfg] {
echo "Executing up task `setup-users` with config" $cfg
todo "Implement setup-users"
debug $"Configuring users with config ($cfg)"
( open /etc/sudoers
| str replace "^# (%wheel ALL=(ALL:ALL) ALL)$" "$1"
| $in + "\nDefaults pwfeedback\n"
| save -f /etc/sudoers )
mkdir /var/lib/AccountsService/users
$cfg | each { |$user_cfg| create_user $user_cfg }
}

Loading…
Cancel
Save