PortValhalla/scripts/Common/Scripts/software.fish

56 lines
1.7 KiB
Fish
Raw Normal View History

#!/bin/env fish
begin
set -l dir (status dirname)
functions -e installSW
functions -e configureSW
functions -e userConfig
function runPSUserAction -a script action name
pwsh -CommandWithArgs '& $args[0] $args[1] @{ name=$args[2]; }' "$script" "$action" "$name"
end
function runPSUserConfig -a script name
runPSUserAction "$script" ConfigureUser "$name"
end
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
end
function runInstallerAction -V dir -a name action
2024-09-13 12:47:07 +00:00
source "$dir/config.fish"
2024-10-06 19:25:34 +00:00
if [ -z "$action" ] || [ "$action" = install ]
if functions -q installSW
echo "Installing `$name`..."
installSW $argv[3..]
end
2024-10-06 19:25:34 +00:00
runInstallerAction $name configure
if not isConfigured || [ "$USER" != (getConfig "valhalla.setupUser.name") ]
runInstallerAction $name userConfig
end
2024-10-06 19:25:34 +00:00
else if [ "$action" = configure ]
if functions -q configureSW
echo "Configuring `$name`..."
configureSW $argv[3..]
end
2024-10-06 19:25:34 +00:00
else if [ "$action" = userConfig ]
set -l user $argv[3]
if [ -z "$user" ]
set user "$USER"
end
if functions -q userConfig
echo "Configuring `$name` for `$user`..."
userConfig "$user" $argv[4..]
end
end
end
end