Add a separate function for executing software actions

This commit is contained in:
Manuel Thalmann 2024-08-06 16:54:11 +02:00
parent f4f568dafe
commit 4e4d273cc7

View file

@ -12,6 +12,7 @@ $null = New-Module {
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../Scripts/Update.ps1";
. "$PSScriptRoot/../Types/InstallerAction.ps1";
<#
.SYNOPSIS
@ -92,6 +93,33 @@ $null = New-Module {
Restart-Intermediate;
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) {
([SetupStage]::Configure) {
@ -114,15 +142,7 @@ $null = New-Module {
}
([SetupStage]::Install) {
Write-Host "Entering install phase";
# Windows Config
. "$PSScriptRoot/../Software/Windows/Manage.ps1";
if (Test-Collection "essential") {
# Essentials
. "$PSScriptRoot/../Software/OpenSSH/Manage.ps1";
}
Deploy-SoftwareAction;
Set-IsFinished $true;
}
}