Create a separate script for WSL interaction

This commit is contained in:
Manuel Thalmann 2024-08-26 23:33:46 +02:00
parent 11d8c853c0
commit 97770288c0
4 changed files with 29 additions and 11 deletions

View file

@ -1,7 +0,0 @@
<#
.SYNOPSIS
Gets the name of the WSL distribution used for reading configuration values.
#>
function Get-DistributionName {
return "ValhallaUbuntu";
}

View file

@ -1,9 +1,9 @@
. "$PSScriptRoot/Config.ps1";
. "$PSScriptRoot/Constants.ps1";
. "$PSScriptRoot/../Types/OneShotTask.ps1";
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
. "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
$null = New-Module {
. "$PSScriptRoot/../Types/OneShotTask.ps1";

View file

@ -7,6 +7,7 @@ using namespace System.Security.Principal;
. "$PSScriptRoot/Manage.ps1";
. "$PSScriptRoot/User/Install.ps1";
. "$PSScriptRoot/../Scripts/Security.ps1";
. "$PSScriptRoot/../Scripts/WSL.ps1";
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
. "$PSScriptRoot/../../Common/Types/OneShotTask.ps1";
@ -18,7 +19,6 @@ $null = New-Module {
. "$PSScriptRoot/../Scripts/Security.ps1";
. "$PSScriptRoot/../Scripts/Update.ps1";
. "$PSScriptRoot/../Scripts/Users.ps1";
. "$PSScriptRoot/../../Common/Scripts/Constants.ps1";
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
. "$PSScriptRoot/../../Common/Scripts/Software.ps1";
@ -42,8 +42,8 @@ $null = New-Module {
#>
function Start-InstallationLoop {
$distribution = Get-DistributionName;
$wslLocation = "$env:ProgramData/PortValhalla/$distribution";
$wslDisk = "$wslLocation/ext4.vhdx";
$wslLocation = Get-DistributionPath;
$wslDisk = Get-DistributionDisk;
while (-not (Get-IsFinished)) {
switch (Get-Stage) {

View file

@ -0,0 +1,25 @@
$null = New-Module {
<#
.SYNOPSIS
Gets the name of the WSL distribution used for managing the configuration.
#>
function Get-DistributionName {
return "ValhallaUbuntu";
}
<#
.SYNOPSIS
Gets the path to the directory containing the WSL distribution.
#>
function Get-DistributionPath {
return "$env:ProgramData/PortValhalla/$distribution";
}
<#
.SYNOPSIS
Gets the path to the virtual hard disk of the WSL distribution.
#>
function Get-DistributionDisk {
return "$(Get-DistributionPath)/ext4.vhdx";
}
};