2024-07-13 13:12:35 +00:00
|
|
|
#!/bin/env fish
|
|
|
|
set -l dir (status dirname)
|
|
|
|
source "$dir/../Scripts/config.fish"
|
|
|
|
source "$dir/../Scripts/hooks.fish"
|
|
|
|
|
|
|
|
if [ (id -u) -eq 0 ]
|
|
|
|
set -l name (getConfig valhalla.setupUser.name)
|
|
|
|
set -l sudoConfig "/etc/sudoers.d/PortValhalla"
|
2024-07-29 22:54:43 +00:00
|
|
|
rm ~/.bash_profile
|
2024-07-13 13:12:35 +00:00
|
|
|
|
|
|
|
runHook createUser || \
|
|
|
|
begin
|
|
|
|
useradd \
|
|
|
|
--comment "PortValhalla setup user" \
|
|
|
|
--system \
|
|
|
|
--no-user-group \
|
2024-07-15 11:17:00 +00:00
|
|
|
--groups wheel,nix-users \
|
2024-07-13 13:12:35 +00:00
|
|
|
--create-home \
|
|
|
|
--uid (getConfig valhalla.setupUser.id --json) \
|
|
|
|
"$name"
|
|
|
|
end
|
|
|
|
|
|
|
|
and begin
|
|
|
|
echo "$name ALL=(ALL:ALL) NOPASSWD: ALL"
|
|
|
|
end > "$sudoConfig"
|
|
|
|
|
2024-09-08 15:09:01 +00:00
|
|
|
and sudo --preserve-env="CONFIG_NAME" --user "$name" "$INSTALLER_SCRIPT"
|
2024-07-13 13:12:35 +00:00
|
|
|
rm "$sudoConfig"
|
2024-07-13 13:49:55 +00:00
|
|
|
userdel -r "$name"
|
2024-07-13 13:12:35 +00:00
|
|
|
else
|
2024-07-16 01:36:51 +00:00
|
|
|
source "$dir/../Software/bash/main.fish"
|
2024-09-12 21:17:04 +00:00
|
|
|
|
|
|
|
if not type -q getDeploymentScript
|
|
|
|
function getDeploymentScript
|
|
|
|
echo "No deployment script specified! No software will be installed." 1>&2
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-07-13 13:49:55 +00:00
|
|
|
runHook initialize || true
|
|
|
|
runHook installDrivers || true
|
|
|
|
runHook installOS || true
|
2024-07-19 22:46:02 +00:00
|
|
|
|
|
|
|
runHook addUsers || begin
|
|
|
|
source "$dir/users.fish"
|
|
|
|
end
|
|
|
|
|
2024-09-12 21:17:04 +00:00
|
|
|
runHook installSoftware || begin
|
|
|
|
set -l script (getDeploymentScript)
|
|
|
|
|
|
|
|
if [ -n "$script" ]
|
|
|
|
source $script
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-07-20 01:13:17 +00:00
|
|
|
runHook initializeConfig || true
|
|
|
|
|
2024-07-13 13:49:55 +00:00
|
|
|
runHook postInstall || true
|
2024-07-13 13:12:35 +00:00
|
|
|
end
|