From 89183dbeed8a335498d92520456dd4ba39894502 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 31 Jul 2024 16:15:09 +0200 Subject: [PATCH] Implement install loop properly --- scripts/Windows/OS/Install.ps1 | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index a97cc4f5..a0bda946 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -30,25 +30,28 @@ function Start-InstallationLoop { while (-not (Get-IsFinished)) { switch (Get-Stage) { $null { - Invoke-Hook "Start-Initialization" -Fallback { - if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) { + if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) { + Invoke-Hook "Install-Chocolatey" -Fallback { # Install chocolatey [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')); Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1; refreshenv; - } - - if (-not (Test-ChocoSoftware "powershell-core")) { + }; + } + + if (-not (Test-ChocoSoftware "powershell-core")) { + Invoke-Hook "Install-PowerShellCore" -Fallback { choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"'; - Restart-Intermediate; - return; - } - - if (Test-Path $env:PWSH_PATH) { - Remove-Item -Recurse $env:PWSH_PATH; - } - }; + }; + + Restart-Intermediate; + return; + } + + if (Test-Path $env:PWSH_PATH) { + Remove-Item -Recurse $env:PWSH_PATH; + } } Default {} }