2024-07-13 16:36:24 +00:00
|
|
|
#!/bin/env fish
|
|
|
|
begin
|
2024-07-20 01:50:38 +00:00
|
|
|
set -l dir (status dirname)
|
|
|
|
|
2024-09-21 15:32:49 +00:00
|
|
|
functions -e installSW
|
|
|
|
functions -e configureSW
|
|
|
|
functions -e userConfig
|
2024-07-13 16:36:24 +00:00
|
|
|
|
2024-09-21 15:32:49 +00:00
|
|
|
function runInstaller -V dir -a action
|
|
|
|
set -l path (status stack-trace | head -n4 | tail -n1 | string replace --regex -- '^\s*called on line \d+ of file (.*)$' '$1')
|
|
|
|
set -l name (basename (dirname $path))
|
|
|
|
runInstallerAction $name $argv
|
2024-07-20 01:50:38 +00:00
|
|
|
end
|
|
|
|
|
2024-09-21 15:32:49 +00:00
|
|
|
function runInstallerAction -V dir -a name action
|
2024-09-13 12:47:07 +00:00
|
|
|
source "$dir/config.fish"
|
|
|
|
|
2024-07-13 16:36:24 +00:00
|
|
|
if [ -z "$action" ] || [ "$action" = "install" ]
|
2024-09-21 15:32:49 +00:00
|
|
|
if functions -q installSW
|
|
|
|
echo "Installing `$name`..."
|
|
|
|
installSW $argv[3..]
|
|
|
|
end
|
|
|
|
|
|
|
|
runInstallerAction $name "configure"
|
2024-07-20 01:50:38 +00:00
|
|
|
|
2024-07-20 12:06:25 +00:00
|
|
|
if not isConfigured || [ "$USER" != (getConfig "valhalla.setupUser.name") ]
|
2024-09-21 15:32:49 +00:00
|
|
|
runInstallerAction $name userConfig
|
2024-07-20 12:06:25 +00:00
|
|
|
end
|
2024-09-13 12:47:07 +00:00
|
|
|
else if [ "$action" = "configure" ]
|
2024-09-21 15:32:49 +00:00
|
|
|
if functions -q configureSW
|
|
|
|
echo "Configuring `$name`..."
|
|
|
|
configureSW $argv[3..]
|
|
|
|
end
|
2024-07-20 01:50:38 +00:00
|
|
|
else if [ "$action" = "userConfig" ]
|
2024-09-21 15:32:49 +00:00
|
|
|
set -l user $argv[3]
|
2024-07-20 01:50:38 +00:00
|
|
|
|
2024-09-21 15:32:49 +00:00
|
|
|
if [ -z "$user" ]
|
|
|
|
set user "$USER"
|
2024-07-20 01:50:38 +00:00
|
|
|
end
|
|
|
|
|
2024-09-21 15:32:49 +00:00
|
|
|
if functions -q userConfig
|
|
|
|
echo "Configuring `$name` for `$user`..."
|
|
|
|
userConfig "$user" $argv[4..]
|
|
|
|
end
|
2024-07-13 16:36:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|