Add a separate function for executing software actions

This commit is contained in:
Manuel Thalmann 2024-08-06 16:54:11 +02:00
parent 6e3e8eb4b3
commit faeac1fdb9

View file

@ -13,6 +13,7 @@ $null = New-Module {
. "$PSScriptRoot/../Scripts/PowerManagement.ps1"; . "$PSScriptRoot/../Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../Scripts/SoftwareManagement.ps1"; . "$PSScriptRoot/../Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../Scripts/Update.ps1"; . "$PSScriptRoot/../Scripts/Update.ps1";
. "$PSScriptRoot/../Types/InstallerAction.ps1";
<# <#
.SYNOPSIS .SYNOPSIS
@ -94,6 +95,33 @@ $null = New-Module {
return; return;
} }
<#
.SYNOPSIS
Deploys an action for each software.
.PARAMETER Action
The action to execute by default.
#>
function Deploy-SoftwareAction {
param(
[InstallerAction] $Action
)
$arguments = [hashtable]@{ };
if ($Action) {
$arguments.Add("action", $Action);
}
# Windows Config
. "$PSScriptRoot/../Software/Windows/Manage.ps1" @arguments;
if (Test-Collection "essential") {
# Essentials
. "$PSScriptRoot/../Software/OpenSSH/Manage.ps1" @arguments;
}
}
switch (Get-Stage) { switch (Get-Stage) {
([SetupStage]::Configure) { ([SetupStage]::Configure) {
if (Get-Config "valhalla.windows.dualboot.enable") { if (Get-Config "valhalla.windows.dualboot.enable") {
@ -115,15 +143,7 @@ $null = New-Module {
} }
([SetupStage]::Install) { ([SetupStage]::Install) {
Write-Host "Entering install phase"; Write-Host "Entering install phase";
Deploy-SoftwareAction;
# Windows Config
. "$PSScriptRoot/../Software/Windows/Manage.ps1";
if (Test-Collection "essential") {
# Essentials
. "$PSScriptRoot/../Software/OpenSSH/Manage.ps1";
}
Set-IsFinished $true; Set-IsFinished $true;
} }
} }