Automatically create a setup user

This commit is contained in:
Manuel Thalmann 2024-07-13 09:52:30 +02:00
parent e017d8fb64
commit 60d3556f10
3 changed files with 141 additions and 79 deletions
scripts/Common/OS

View file

@ -0,0 +1,32 @@
#!/bin/env fish
begin
set -l dir (status dirname)
source "$dir/../Scripts/config.fish"
source "$dir/../Scripts/hooks.fish"
set -l name (getConfig valhalla.setupUser.name)
set -l mountDir (getConfig valhalla.partition.rootDir)
runHook setupOS || true
and runHook createUser || \
begin
chroot "$mountDir" \
useradd \
--comment "PortValhalla setup user" \
--system \
--no-user-group \
--groups wheel \
--create-home \
--uid (getConfig valhalla.setupUser.id --json) \
"$name"
end
chroot "$mountDir" usermod -aG wheel "$name"
begin
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
end | chroot "$mountDir" tee "/etc/sudoers.d/PortValhalla" > /dev/null
and runHook autologin || true
and echo "Setup finished!"
and echo "Please reboot your machine"
end