Remove unused resources after user setup
This commit is contained in:
parent
cfbe29eb0e
commit
fa5b462312
|
@ -14,6 +14,7 @@ enum SetupStage {
|
|||
enum UserStage {
|
||||
Create
|
||||
Configure
|
||||
Cleanup
|
||||
Completed
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,9 @@ $null = New-Module {
|
|||
Starts the installation loop.
|
||||
#>
|
||||
function Start-InstallationLoop {
|
||||
$wslLocation = "$env:ProgramData\PortValhalla\Ubuntu";
|
||||
$distribution = "PortValhalla";
|
||||
$wslLocation = "$env:ProgramData/PortValhalla/Ubuntu";
|
||||
$wslDisk = "$wslLocation/ext4.vhdx";
|
||||
|
||||
while (-not (Get-IsFinished)) {
|
||||
switch (Get-Stage) {
|
||||
|
@ -195,8 +197,8 @@ $null = New-Module {
|
|||
}
|
||||
default {
|
||||
if (-not (& { $null = wsl -l; $? })) {
|
||||
wsl --import-in-place "PortValhalla" "$wslLocation/ext4.vhdx";
|
||||
wsl --set-default "PortValhalla";
|
||||
wsl --import-in-place $distribution "$wslDisk";
|
||||
wsl --set-default $distribution;
|
||||
}
|
||||
|
||||
switch ($_) {
|
||||
|
@ -610,7 +612,18 @@ $null = New-Module {
|
|||
Add-LocalGroupMember -Member "$name" -Name "$group";
|
||||
}
|
||||
|
||||
Set-UserStage ([UserStage]::Cleanup);
|
||||
}
|
||||
([UserStage]::Cleanup) {
|
||||
$user = Get-SetupUser;
|
||||
Enable-LocalUser $user;
|
||||
Set-AutologinUser $user;
|
||||
wsl --shutdown;
|
||||
$tempDisk = Rename-Item -Force $wslDisk "ext4_.vhdx" -PassThru;
|
||||
wsl --unregister $distribution;
|
||||
Move-Item $tempDisk $wslDisk;
|
||||
Set-UserStage ([UserStage]::Completed);
|
||||
Restart-Intermediate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue