PortValhalla/scripts/Common/OS/install.fish

68 lines
1.8 KiB
Fish
Raw Normal View History

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"
rm ~/.bash_profile
2024-07-13 13:12:35 +00:00
runHook createUser || \
begin
useradd \
--comment "PortValhalla setup user" \
--system \
--no-user-group \
--groups 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-19 20:29:34 +00:00
and sudo --preserve-env --set-home --user "$name" "$INSTALLER_SCRIPT"
2024-07-13 13:12:35 +00:00
rm "$sudoConfig"
2024-09-13 13:05:17 +00:00
userdel -rf "$name"
2024-07-13 13:12:35 +00:00
else
if not type -q getDeploymentScript
function getDeploymentScript
echo "No deployment script specified! No software will be installed." 1>&2
false
end
end
set -l deployScript (getDeploymentScript)
2024-07-13 13:49:55 +00:00
runHook initialize || true
2024-09-13 13:10:29 +00:00
and runHook installOS || true
2024-07-19 22:46:02 +00:00
2024-09-13 13:10:29 +00:00
and runHook addUsers || begin
2024-07-19 22:46:02 +00:00
source "$dir/users.fish"
end
2024-09-13 13:31:42 +00:00
and runHook installSoftware || begin
if [ -n "$deployScript" ]
source $deployScript
end
end
runHook initializeUsers || begin
if [ -n "$deployScript" ]
source "$dir/../Scripts/config.fish"
for name in (getUsers | jq '.[]' --raw-output0 | string split0)
source $deployScript userConfig $name
end
end
end
2024-09-13 13:31:42 +00:00
and runHook postInstall || true
2024-09-19 20:29:50 +00:00
echo "The installation finished successfully!"
and echo "This machine will reboot in 5 seconds..."
and echo "Press CTRL-C to abort..."
and sleep 5
2024-09-20 03:35:15 +00:00
and systemctl reboot -i
2024-07-13 13:12:35 +00:00
end