Add setup users task
parent
622f28dfbc
commit
589584c7c6
@ -1,6 +1,28 @@
|
|||||||
let RUN_IN_CHROOT = true;
|
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`
|
# Applies all system changes of `setup-users`
|
||||||
def main [cfg] {
|
def main [cfg] {
|
||||||
echo "Executing up task `setup-users` with config" $cfg
|
debug $"Configuring users with config ($cfg)"
|
||||||
todo "Implement setup-users"
|
( 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…
Reference in New Issue