Ensure the environment variables are always set properly
This commit is contained in:
parent
2bb3007006
commit
901262b8a7
|
@ -4,6 +4,7 @@
|
||||||
. "$PSScriptRoot/Manage.ps1";
|
. "$PSScriptRoot/Manage.ps1";
|
||||||
. "$PSScriptRoot/User/Install.ps1";
|
. "$PSScriptRoot/User/Install.ps1";
|
||||||
. "$PSScriptRoot/../Scripts/Context.ps1";
|
. "$PSScriptRoot/../Scripts/Context.ps1";
|
||||||
|
. "$PSScriptRoot/../Scripts/Operations.ps1";
|
||||||
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
@ -18,14 +19,9 @@ $null = New-Module {
|
||||||
Finishes the installation of a running Windows machine.
|
Finishes the installation of a running Windows machine.
|
||||||
#>
|
#>
|
||||||
function Start-WindowsInstallation {
|
function Start-WindowsInstallation {
|
||||||
$ErrorActionPreference = 'Inquire';
|
Start-Operation {
|
||||||
$env:WSLENV = "CONFIG_MODULE/p";
|
Start-InstallationLoop;
|
||||||
|
};
|
||||||
if ($env:CONFIG_MODULE) {
|
|
||||||
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Start-InstallationLoop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
14
scripts/Windows/Scripts/Operations.ps1
Normal file
14
scripts/Windows/Scripts/Operations.ps1
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
function Start-Operation {
|
||||||
|
param(
|
||||||
|
[scriptblock] $Action
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Inquire';
|
||||||
|
$env:WSLENV = "CONFIG_MODULE/p";
|
||||||
|
|
||||||
|
if ($env:CONFIG_MODULE) {
|
||||||
|
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
& $Action;
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
. "$PSScriptRoot/Config.ps1";
|
. "$PSScriptRoot/Config.ps1";
|
||||||
|
. "$PSScriptRoot/Operations.ps1";
|
||||||
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
@ -15,51 +16,53 @@ $null = New-Module {
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not $Name) {
|
Start-Operation {
|
||||||
$Name = Split-Path -Leaf (Split-Path -Parent ((Get-PSCallStack)[1].ScriptName));
|
if (-not $Name) {
|
||||||
}
|
$Name = Split-Path -Leaf (Split-Path -Parent ((Get-PSCallStack)[1].ScriptName));
|
||||||
|
}
|
||||||
|
|
||||||
if ($null -ne $Name) {
|
if ($null -ne $Name) {
|
||||||
$Name = "``$Name``";
|
$Name = "``$Name``";
|
||||||
} else {
|
} else {
|
||||||
$Name = "unknown software";
|
$Name = "unknown software";
|
||||||
}
|
}
|
||||||
|
|
||||||
$installHandler = {
|
$installHandler = {
|
||||||
param(
|
param(
|
||||||
[InstallerAction] $Action,
|
[InstallerAction] $Action,
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
$Arguments ??= @{ };
|
$Arguments ??= @{ };
|
||||||
|
|
||||||
$argumentList = @{
|
$argumentList = @{
|
||||||
installer = $installHandler;
|
installer = $installHandler;
|
||||||
arguments = $Arguments;
|
arguments = $Arguments;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($action -eq ([InstallerAction]::Install)) {
|
||||||
|
Write-Host "Installing $Name…";
|
||||||
|
& $Installer @argumentList;
|
||||||
|
} elseif ($Action -eq ([InstallerAction]::Configure)) {
|
||||||
|
Write-Host "Configuring $Name…";
|
||||||
|
& $Configurator @argumentList;
|
||||||
|
|
||||||
|
foreach ($user in Get-Users) {
|
||||||
|
$Arguments.Add($userArgument, $user);
|
||||||
|
$argumentList.Add("action", [InstallerAction]::ConfigureUser);
|
||||||
|
& $installHandler @argumentList;
|
||||||
|
}
|
||||||
|
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
||||||
|
if ((-not $Arguments.ContainsKey($userArgument)) -or ($null -eq $Arguments[$userArgument])) {
|
||||||
|
$argumentList.Add($userArgument, ($env:UserName));
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``…";
|
||||||
|
& $UserConfigurator @argumentList;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($action -eq ([InstallerAction]::Install)) {
|
& $installHandler -Action $Action -Arguments $Arguments;
|
||||||
Write-Host "Installing $Name…";
|
|
||||||
& $Installer @argumentList;
|
|
||||||
} elseif ($Action -eq ([InstallerAction]::Configure)) {
|
|
||||||
Write-Host "Configuring $Name…";
|
|
||||||
& $Configurator @argumentList;
|
|
||||||
|
|
||||||
foreach ($user in Get-Users) {
|
|
||||||
$Arguments.Add($userArgument, $user);
|
|
||||||
$argumentList.Add("action", [InstallerAction]::ConfigureUser);
|
|
||||||
& $installHandler @argumentList;
|
|
||||||
}
|
|
||||||
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
|
||||||
if ((-not $Arguments.ContainsKey($userArgument)) -or ($null -eq $Arguments[$userArgument])) {
|
|
||||||
$argumentList.Add($userArgument, ($env:UserName));
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``…";
|
|
||||||
& $UserConfigurator @argumentList;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
& $installHandler -Action $Action -Arguments $Arguments;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue