Execute the entire installer using live scripts

This commit is contained in:
Manuel Thalmann 2024-08-21 23:21:32 +02:00
parent 008af9891a
commit 4a3e497532

View file

@ -46,20 +46,6 @@ $null = New-Module {
break; break;
} }
([SetupStage]::Initialize) { ([SetupStage]::Initialize) {
if ($env:DEBUG) {
& {
$sys32 = "$env:WINDIR/System32";
$osk = "$sys32/osk.exe";
$cmd = "$sys32/cmd.exe";
if ((Get-FileHash $osk) -ne (Get-FileHash $cmd)) {
Rename-Item $osk "${osk}_";
Copy-Item $cmd $osk;
continue;
}
};
}
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) { if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback { Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey # Install chocolatey
@ -72,25 +58,25 @@ $null = New-Module {
continue; continue;
} }
if (-not (Test-Command "gsudo")) {
Install-ChocoPackage gsudo;
refreshenv;
continue;
}
if (-not (Test-Command "git")) {
Install-ChocoPackage git;
refreshenv;
continue;
}
if (-not (Test-ChocoPackage "powershell-core")) { if (-not (Test-ChocoPackage "powershell-core")) {
Invoke-Hook "Install-PowerShellCore" -Fallback { 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"'; 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 ($env:PWSH_PATH -and (Test-Path $env:PWSH_PATH)) {
attrib "-R" "$env:PWSH_PATH\*" /S /D;
Remove-Item -Recurse -Force $env:PWSH_PATH;
continue;
}
if ($env:DEBUG) { if ($env:DEBUG) {
if ( if (
(Get-Item $env:INSTALLER_SCRIPT).IsReadOnly -and
(Test-Qemu) -and (Test-Qemu) -and
($Host.UI.PromptForChoice( ($Host.UI.PromptForChoice(
"Confirm", "Confirm",
@ -116,16 +102,35 @@ $null = New-Module {
Set-Item "Env:\$name" $path; Set-Item "Env:\$name" $path;
Write-Host "The new value of ``$name`` is ``$path``"; Write-Host "The new value of ``$name`` is ``$path``";
} }
}
}
Restart-Intermediate; Restart-Intermediate;
return; exit;
}
} }
if ($env:PWSH_PATH -and (Test-Path $env:PWSH_PATH)) { if ($env:DEBUG) {
attrib "-R" "$env:PWSH_PATH\*" /S /D; & {
Remove-Item -Recurse -Force $env:PWSH_PATH; $sys32 = "$env:WINDIR/System32";
$osk = "$sys32/osk.exe";
$cmd = "$sys32/cmd.exe";
if ((Get-FileHash $osk) -ne (Get-FileHash $cmd)) {
Rename-Item $osk "${osk}_";
Copy-Item $cmd $osk;
continue;
}
};
}
if (-not (Test-Command "gsudo")) {
Install-ChocoPackage gsudo;
refreshenv;
continue;
}
if (-not (Test-Command "git")) {
Install-ChocoPackage git;
refreshenv;
continue; continue;
} }
@ -593,14 +598,14 @@ $null = New-Module {
foreach ($group in Get-UserConfig -UserName $name "groups") { foreach ($group in Get-UserConfig -UserName $name "groups") {
Add-LocalGroupMember -Member $name -Name "$group"; Add-LocalGroupMember -Member $name -Name "$group";
} }
}
}
}
if (-not $msAccount) { if (-not $msAccount) {
net user $name /logonpasswordchg:yes; net user $name /logonpasswordchg:yes;
} }
} }
}
}
}
Set-IsFinished $true; Set-IsFinished $true;
} }