PortValhalla/scripts/Common/OS/setup.fish

41 lines
1.3 KiB
Fish
Raw Normal View History

2024-07-13 07:52:30 +00:00
#!/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)
set -l projectRoot (realpath "$dir/../../..")
set -l projectName (basename "$projectRoot")
set -l PROJECT_CLONE_ROOT "/opt/$(basename "$projectName")"
2024-07-13 09:23:14 +00:00
set -l script (mktemp)
2024-07-13 09:23:14 +00:00
getConfig valhalla.partition.script > "$script"
bash "$script"
and source "$dir/../../copy-repo.fish" "$mountDir$PROJECT_CLONE_ROOT"
and runHook setupOS || true
2024-07-13 07:52:30 +00:00
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