|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +Invoke-RestMethod -Uri https://aka.ms/downloadazcopy-v10-linux -OutFile azcopy_v10.tar.gz |
| 4 | +tar -xvzf azcopy_v10.tar.gz --strip-components=1 |
| 5 | +./azcopy --version |
| 6 | +$AZCOPY_AUTO_LOGIN_TYPE="MSI" |
| 7 | +$AZCOPY_MSI_CLIENT_ID=${Env:CLIENTID} |
| 8 | +echo "principal id: ${Env:PRINCIPALID}" |
| 9 | +echo "tenant id: ${Env:TENANTID}" |
| 10 | +$AZCOPY_REQUEST_TRY_TIMEOUT=1 |
| 11 | + |
| 12 | +if ( ${Env:ARCHITECTURE} -eq 'x86' ) { |
| 13 | + ${Env:DEB_ARCHITECTURE} = 'amd64' |
| 14 | + ${Env:RPM_ARCHITECTURE} = 'x86_64' |
| 15 | +} |
| 16 | +elseif (${Env:ARCHITECTURE} -eq 'ARM') { |
| 17 | + ${Env:DEB_ARCHITECTURE} = 'arm64' |
| 18 | + ${Env:RPM_ARCHITECTURE} = 'aarch64' |
| 19 | +} |
| 20 | +else { |
| 21 | + Write-Host '[ERROR] unsupported architecture found.' |
| 22 | + exit 1 |
| 23 | +} |
| 24 | + |
| 25 | +if ( ${Env:OPENSSLVERSION} -eq '3' ) { |
| 26 | + ${Env:DEB_PLATFORM_PATH} = 'ubuntu/pool/noble' |
| 27 | + ${Env:RPM_PLATFORM_PATH} = 'amazonlinux/2023' |
| 28 | +} |
| 29 | +elseif ( ${Env:OPENSSLVERSION} -eq '1' ) { |
| 30 | + ${Env:DEB_PLATFORM_PATH} = 'debian/pool/bullseye' |
| 31 | + ${Env:RPM_PLATFORM_PATH} = 'amazonlinux/2' |
| 32 | +} |
| 33 | +else { |
| 34 | + Write-Host '[ERROR] unsupported openssl version found.' |
| 35 | + exit 1 |
| 36 | +} |
| 37 | + |
| 38 | +Write-Host "[INFO] architecture is: ${Env:ARCHITECTURE}" |
| 39 | +Write-Host "[INFO] rpm platform path is: ${Env:RPM_PLATFORM_PATH}" |
| 40 | +Write-Host "[INFO] deb platform path is: ${Env:DEB_PLATFORM_PATH}" |
| 41 | + |
| 42 | +df -h |
| 43 | + |
| 44 | +$containerUrl = "https://senzing.blob.core.windows.net/senzing/${Env:ARCHITECTURE}/openssl${Env:OPENSSLVERSION}" |
| 45 | + |
| 46 | +# Get an access token for managed identities for Azure resources |
| 47 | +$response = Invoke-WebRequest -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' ` |
| 48 | + -Headers @{Metadata="true"} |
| 49 | +curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' -H Metadata:true -s |
| 50 | +$content =$response.Content | ConvertFrom-Json |
| 51 | +$access_token = $content.access_token |
| 52 | +echo "The managed identities for Azure resources access token is $access_token" |
| 53 | +
|
| 54 | +echo "[INFO] ./azcopy cp $containerUrl /tmp --recursive --log-level=DEBUG" |
| 55 | +./azcopy cp "$containerUrl" /tmp --recursive --log-level=DEBUG |
| 56 | +
|
| 57 | +df -h |
| 58 | +
|
| 59 | +ls -tlc /tmp |
| 60 | +
|
| 61 | +$StorageAccount = Get-AzStorageAccount -ResourceGroupName ${Env:RESOURCEGROUP} -Name ${Env:STORAGEACCOUNT} |
| 62 | +echo "[INFO] New-AzStorageDirectory -ShareName senzing -Path ${Env:ARCHITECTURE} -Context $storageAccount.Context" |
| 63 | +New-AzStorageDirectory -ShareName 'senzing' -Path "${Env:ARCHITECTURE}" -Context $storageAccount.Context |
| 64 | +echo "[INFO] New-AzStorageDirectory -ShareName senzing -Path ${Env:ARCHITECTURE}/openssl${Env:OPENSSLVERSION} -Context $storageAccount.Context" |
| 65 | +New-AzStorageDirectory -ShareName 'senzing' -Path "${Env:ARCHITECTURE}/openssl${Env:OPENSSLVERSION}" -Context $storageAccount.Context |
| 66 | +
|
| 67 | +$CurrentFolder = (Get-Item .).FullName |
| 68 | +ls -tlc |
| 69 | +pwd |
| 70 | +ls -tlc x86/openssl3/ |
| 71 | +$Container = Get-AzStorageShare -Name 'senzing' -Context $StorageAccount.Context |
| 72 | +echo "[INFO] New-AzStorageDirectory -ShareName senzing -Path ${Env:ARCHITECTURE} -Context $storageAccount.Context" |
| 73 | +New-AzStorageDirectory -ShareName 'senzing' -Path "${Env:ARCHITECTURE}" -Context $storageAccount.Context |
| 74 | +echo "[INFO] New-AzStorageDirectory -ShareName senzing -Path ${Env:ARCHITECTURE}/openssl${Env:OPENSSLVERSION} -Context $storageAccount.Context" |
| 75 | +New-AzStorageDirectory -ShareName 'senzing' -Path "${Env:ARCHITECTURE}/openssl${Env:OPENSSLVERSION}" -Context $storageAccount.Context |
| 76 | +Get-ChildItem -Recurse | Where-Object { $_.GetType().Name -eq "FileInfo"} | ForEach-Object { |
| 77 | + $path=$_.FullName.Substring($Currentfolder.Length+1).Replace("\","/") |
| 78 | + Write-Host "[INFO] Set-AzStorageFileContent -ShareName 'senzing' -Source $_ -Path $path -Force -Context" |
| 79 | + Set-AzStorageFileContent -ShareName 'senzing' -Source "$_" -Path "$path" -Force -Context $storageAccount.Context |
| 80 | +} |
0 commit comments