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