Last active
November 17, 2022 14:32
-
-
Save t1m0thyj/a938ab0d21bb2526555531c2c53ded54 to your computer and use it in GitHub Desktop.
Zowe install test scripts for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update variables in this file before running the script | |
TEST_PACKAGE_DIR=../zowe-cli-package-X.Y.Z | |
TEST_OFFLINE=no | |
TEST_V1LTS=no | |
TEST_HOST=example.com | |
TEST_ZOSMF_PORT=443 | |
TEST_APIML_PORT=7554 | |
TEST_USER=XXX | |
TEST_PASSWORD=XXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Before running this script, you need the following prerequisites: | |
* Windows Sandbox - optional feature built-in to Windows | |
https://learn.microsoft.com/en-us/windows/security/threat-protection/windows-sandbox/windows-sandbox-overview | |
* PowerShell 7 - temporary requirement because PowerShell in Sandbox is broken | |
Download the ZIP from the link and extract it inside a "PowerShell7" folder. | |
https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3#installing-the-zip-package | |
#> | |
$ErrorActionPreference = "Stop" | |
# Launch Windows sandboxes from host | |
if ($env:UserName -ne "WDAGUtilityAccount") { | |
New-Item logs -ItemType Directory -ErrorAction Ignore | |
Remove-Item logs\* -Force | |
@(12, 14, 16, 18) | foreach { | |
Set-Content temp.cmd @" | |
cd C:\Users\WDAGUtilityAccount\Desktop\SandboxScripts | |
set NODE_VERSION=$_.x | |
start .\PowerShell7\pwsh -NoExit -ExecutionPolicy Bypass -File .\zowe-install-test.ps1 | |
"@ | |
& "$env:SystemRoot\System32\WindowsSandbox.exe" zowe-install-test.wsb | |
while (Test-Path temp.cmd) { | |
Start-Sleep -Seconds 1 | |
} | |
Get-Process "WindowsSandboxClient" | Stop-Process | |
Start-Sleep -Seconds 5 | |
} | |
exit | |
} | |
# Load environment variables | |
Get-Content zowe-install-test.env | foreach { | |
if (!$_.StartsWith("#")) { | |
$name, $value = $_.split("=") | |
Set-Content Env:\$name $value | |
} | |
} | |
# Install Node.js and npm | |
if ($env:NODE_VERSION.Length -gt 0) { | |
Start-Transcript -Path logs\$(Split-Path $env:TEST_PACKAGE_DIR -Leaf)_windows-$env:NODE_VERSION.log | |
$response = Invoke-WebRequest https://nodejs.org/download/release/latest-v$env:NODE_VERSION -UseBasicParsing | |
$x64Msi = $response.Links |? { $_.href -Match "-x64.msi" } | |
(New-Object Net.WebClient).DownloadFile("https://nodejs.org/download/release/latest-v$env:NODE_VERSION/$($x64Msi.href)", "$env:Temp\node-$env:NODE_VERSION.msi") | |
msiexec /I $env:Temp\node-$env:NODE_VERSION.msi /passive | Out-Null | |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") | |
} | |
# Download prerequisites for DB2 and SCS | |
if ($env:TEST_OFFLINE -eq "yes") { | |
(New-Object Net.WebClient).DownloadFile("https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip", "$env:Temp\ntx64_odbc_cli.zip") | |
$env:IBM_DB_INSTALLER_URL = $env:Temp | |
} else { | |
Remove-Item Env:\IBM_DB_INSTALLER_URL -ErrorAction Ignore | |
} | |
# Install Zowe CLI and plug-ins | |
Push-Location $env:TEST_PACKAGE_DIR | |
if ($env:TEST_OFFLINE -eq "yes") { Disable-NetAdapter -Name "Ethernet" -Confirm:$false } | |
try { | |
npm install -g zowe-cli.tgz | |
$plugins = $(Get-ChildItem *-for-zowe-cli.tgz -Name) | |
zowe plugins install @plugins | |
} finally { | |
Pop-Location | |
if ($env:TEST_OFFLINE -eq "yes") { Enable-NetAdapter -Name "Ethernet" -Confirm:$false } | |
} | |
# Display versions of installed components | |
node --version | |
npm --version | |
zowe --version | |
zowe plugins list --short | |
# Create profile and verify it works | |
if ($env:TEST_V1LTS -eq "yes") { | |
zowe profiles create zosmf ibmzosmf --host $env:TEST_HOST --port $env:TEST_ZOSMF_PORT --user $env:TEST_USER --password $env:TEST_PASSWORD | |
zowe profiles list zosmf --sc | |
} else { | |
zowe config auto-init --gc --host $env:TEST_HOST --port $env:TEST_APIML_PORT --user $env:TEST_USER --password $env:TEST_PASSWORD | |
Get-Content $env:UserProfile\.zowe\zowe.config.json | |
} | |
zowe files list ds "$env:TEST_USER.*" --zosmf-p ibmzosmf | |
# Delete temp file to end sandbox session | |
if ($env:UserName -eq "WDAGUtilityAccount") { | |
Remove-Item temp.cmd -Force | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Configuration> | |
<MappedFolders> | |
<MappedFolder> | |
<HostFolder>C:\Users\Public\Documents\</HostFolder> | |
<ReadOnly>false</ReadOnly> | |
</MappedFolder> | |
</MappedFolders> | |
<LogonCommand> | |
<Command>C:\Users\WDAGUtilityAccount\Desktop\SandboxScripts\temp.cmd</Command> | |
</LogonCommand> | |
</Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment