Refactor the installation loop architecture

This commit is contained in:
Manuel Thalmann 2024-07-31 16:25:32 +02:00
parent 60dc4af97e
commit 382e3aac61
2 changed files with 36 additions and 25 deletions

View file

@ -28,8 +28,10 @@ function Start-InstallationLoop {
. "$PSScriptRoot/../Scripts/SetupConfig.ps1"; . "$PSScriptRoot/../Scripts/SetupConfig.ps1";
while (-not (Get-IsFinished)) { while (-not (Get-IsFinished)) {
switch (Get-Stage) { if (-not (Get-Stage)) {
$null { Set-Stage [SetupStage]::Initialize;
break;
} elseif (Get-Stage -eq [SetupStage]::Initialize) {
if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) { if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback { Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey # Install chocolatey
@ -52,10 +54,14 @@ function Start-InstallationLoop {
if (Test-Path $env:PWSH_PATH) { if (Test-Path $env:PWSH_PATH) {
Remove-Item -Recurse $env:PWSH_PATH; Remove-Item -Recurse $env:PWSH_PATH;
} }
} else {
switch (Get-Stage) {
$null {
} }
Default {} Default {}
} }
} }
}
} }
function Invoke-WindowsInstallation([Context] $context) { function Invoke-WindowsInstallation([Context] $context) {

View file

@ -2,6 +2,11 @@ using namespace Microsoft.Win32;
using namespace System.Security.AccessControl; using namespace System.Security.AccessControl;
using namespace System.Security.Principal; using namespace System.Security.Principal;
enum SetupStage {
Initialize = "init"
Install = "install"
}
$null = New-Module { $null = New-Module {
[string] $configRoot = "HKLM:\Software\PortValhalla"; [string] $configRoot = "HKLM:\Software\PortValhalla";
[string] $stageOption = "Stage"; [string] $stageOption = "Stage";