Compare commits

...

5 commits

4 changed files with 66 additions and 25 deletions

View file

@ -12,6 +12,7 @@ $null = New-Module {
. "$PSScriptRoot/../Scripts/Hooks.ps1";
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../Scripts/Registry.ps1";
. "$PSScriptRoot/../Scripts/Security.ps1";
. "$PSScriptRoot/../Scripts/Update.ps1";
. "$PSScriptRoot/../Scripts/Users.ps1";
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
@ -35,6 +36,8 @@ $null = New-Module {
Starts the installation loop.
#>
function Start-InstallationLoop {
$wslLocation = "$env:ProgramData\PortValhalla\Ubuntu";
while (-not (Get-IsFinished)) {
switch (Get-Stage) {
($null) {
@ -93,7 +96,15 @@ $null = New-Module {
}
if (-not (& { $null = wsl -l; $?; })) {
ubuntu install --root;
$wslRoot = Split-Path -Parent $wslLocation;
if (-not (Test-Path -PathType $wslRoot)) {
$null = New-Item -ItemType Directory $wslRoot;
}
Copy-Item -Recurse (Get-AppxPackage "*Ubuntu*").InstallLocation $wslLocation;
Set-UserPermissions $wslLocation;
& "$wslLocation\ubuntu.exe" install --root;
continue;
}
@ -123,15 +134,22 @@ $null = New-Module {
break;
}
default {
$null = Import-Module PSWindowsUpdate;
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
Update-WindowsInstallation;
};
if ((Get-WURebootStatus -Silent)) {
Restart-Intermediate;
return;
if (-not (& { $null = wsl -l; $? })) {
wsl --import-in-place "PortValhalla" "$wslLocation/ext4.vhdx";
wsl --set-default "PortValhalla";
}
if (Test-Admin) {
$null = Import-Module PSWindowsUpdate;
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
Update-WindowsInstallation;
};
if ((Get-WURebootStatus -Silent)) {
Restart-Intermediate;
return;
}
}
<#
@ -450,7 +468,10 @@ $null = New-Module {
[string[]] $users = Get-Users;
$currentUser = Get-CurrentUser;
Disable-BootMessage;
if (Test-Admin) {
Disable-BootMessage;
}
if ($currentUser -lt $users.Count) {
$user = Get-LocalUser $users[$currentUser];

View file

@ -141,7 +141,7 @@ $null = New-Module {
[switch] $DefaultUser
)
$register = { param($Key) Register-Setup -UserKey $Key; };
$register = { param($UserKey) Register-Setup @PSBoundParameters; };
if ($DefaultUser) {
Edit-DefaultUserKey {
@ -149,11 +149,12 @@ $null = New-Module {
[RegistryKey] $Key
)
& $register -Key $Key;
& $register $Key;
}
} else {
& $register;
}
& $register;
Read-Host "Press enter to reboot";
Restart-Computer -Force;
}

View file

@ -1,3 +1,6 @@
using namespace System.Security.AccessControl;
using namespace System.Security.Principal;
$null = New-Module {
$uacOption = "EnableLUA";
$systemPolicyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
@ -33,4 +36,29 @@ $null = New-Module {
function Disable-UAC {
& $uacSetter $false;
}
<#
.SYNOPSIS
Sets read/write permissions for users at the specified path.
.PARAMETER Path
The path to allow access to users.
#>
function Set-UserPermissions {
param(
[string] $Path
)
$acl = Get-Acl $Path;
$acl.AddAccessRule(
[FileSystemAccessRule]::new(
[SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null),
[FileSystemRights]::FullControl,
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit,
[PropagationFlags]::InheritOnly,
[AccessControlType]::Allow));
Set-Acl $Path $acl;
}
};

View file

@ -6,6 +6,7 @@ param(
[hashtable] $Arguments
)
. "$PSScriptRoot/../../Scripts/Security.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
@ -19,18 +20,8 @@ Start-SoftwareInstaller @PSBoundParameters `
git clone "https://github.com/jasongin/nvs.git" $env:NVS_HOME;
& "$env:NVS_HOME\nvs.cmd" install;
$acl = Get-Acl $env:NVS_HOME;
$acl.AddAccessRule(
[FileSystemAccessRule]::new(
[SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null),
[FileSystemRights]::FullControl,
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit,
[PropagationFlags]::InheritOnly,
[AccessControlType]::Allow));
Set-Acl $env:NVS_HOME $acl;
refreshenv;
Set-UserPermissions $env:NVS_HOME;
& $Installer -Action ([InstallerAction]::Configure);
} `
-Configurator {