You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
859 B
Plaintext
29 lines
859 B
Plaintext
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] {
|
|
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 }
|
|
}
|