Remove unused resources after user setup
This commit is contained in:
parent
4608c4748c
commit
a5f1f06ca0
2 changed files with 18 additions and 3 deletions
|
@ -14,6 +14,7 @@ enum SetupStage {
|
||||||
enum UserStage {
|
enum UserStage {
|
||||||
Create
|
Create
|
||||||
Configure
|
Configure
|
||||||
|
Cleanup
|
||||||
Completed
|
Completed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,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) {
|
||||||
|
@ -198,8 +200,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 ($_) {
|
||||||
|
@ -617,7 +619,19 @@ $null = New-Module {
|
||||||
net user $name /logonpasswordchg:yes;
|
net user $name /logonpasswordchg:yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue