Refactor the installation loop architecture
This commit is contained in:
parent
73c0648611
commit
467ad0caab
2 changed files with 36 additions and 25 deletions
|
@ -29,8 +29,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
|
||||||
|
@ -53,11 +55,15 @@ 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) {
|
||||||
$Global:InformationPreference = "Continue";
|
$Global:InformationPreference = "Continue";
|
||||||
|
|
|
@ -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";
|
||||||
|
|
Loading…
Reference in a new issue