Make scripts platform independent
This commit is contained in:
parent
6b1aee97a6
commit
7fc0a0235c
2 changed files with 26 additions and 18 deletions
|
@ -109,6 +109,8 @@ $null = New-Module {
|
||||||
|
|
||||||
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
||||||
|
|
||||||
|
if ($env:CONFIG_MODULE) {
|
||||||
|
$output = & {
|
||||||
if (-not $IsWindows) {
|
if (-not $IsWindows) {
|
||||||
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
||||||
fish -c ". $escapedPath; $Script";
|
fish -c ". $escapedPath; $Script";
|
||||||
|
@ -122,12 +124,18 @@ $null = New-Module {
|
||||||
if (-not $?) {
|
if (-not $?) {
|
||||||
Write-Error "The configuration could not be retrieved!";
|
Write-Error "The configuration could not be retrieved!";
|
||||||
} else {
|
} else {
|
||||||
|
$output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (-not ($output -and ($output | Test-Json))) {
|
if (-not ($output -and ($output | Test-Json))) {
|
||||||
Write-Error "The value ``$output`` is not valid JSON.";
|
Write-Error "The value ``$output`` is not valid JSON.";
|
||||||
} else {
|
} else {
|
||||||
$output | ConvertFrom-Json;
|
$output | ConvertFrom-Json;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
$null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +416,7 @@ $null = New-Module {
|
||||||
Checks whether the current user is the setup user.
|
Checks whether the current user is the setup user.
|
||||||
#>
|
#>
|
||||||
function Test-SetupUser {
|
function Test-SetupUser {
|
||||||
$env:UserName -eq (Get-Config "valhalla.windows.setupUser");
|
($IsWindows ? $env:UserName : $env:USER) -eq (Get-Config "valhalla.windows.setupUser");
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
|
@ -255,7 +255,7 @@ $null = New-Module {
|
||||||
}
|
}
|
||||||
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
||||||
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
||||||
$Arguments.Add($userArgument, ($env:UserName));
|
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($UserConfigurator) {
|
if ($UserConfigurator) {
|
||||||
|
|
Loading…
Reference in a new issue