Create a separate script for WSL interaction

This commit is contained in:
Manuel Thalmann 2024-08-26 23:33:46 +02:00
parent 1f700ab419
commit 0d9c4c76d5
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

@ -3,6 +3,7 @@ using namespace System.Management.Automation.Host;
using namespace System.Security.Principal;
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
. "$PSScriptRoot/../../../scripts/Windows/Scripts/WSL.ps1";
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
. "$PSScriptRoot/../Scripts/Security.ps1";
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
@ -16,7 +17,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";
@ -39,8 +39,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";
}
};