Files
runner-images/images/linux/scripts/installers/azpowershell.sh
T

44 lines
1.5 KiB
Bash
Raw Normal View History

2019-11-15 15:23:41 -05:00
#!/bin/bash
################################################################################
## File: azpowershell.sh
## Desc: Installed Azure PowerShell
################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh
2020-05-26 18:45:48 +03:00
source $HELPER_SCRIPTS/os.sh
2020-05-29 14:26:08 +03:00
# List of versions
2020-05-26 18:45:48 +03:00
if isUbuntu20 ; then
2020-05-29 14:26:08 +03:00
versions=$(pwsh -Command '(Find-Module -Name Az).Version')
else
versions=(1.0.0 1.6.0 2.3.2 2.6.0 2.8.0 3.1.0 3.5.0 3.8.0)
2020-05-26 18:45:48 +03:00
fi
2019-11-15 15:23:41 -05:00
# Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
2020-05-29 14:26:08 +03:00
for version in ${versions[@]}; do
pwsh -Command "Save-Module -Name Az -LiteralPath /usr/share/az_$version -RequiredVersion $version -Force"
done
2019-11-15 15:23:41 -05:00
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
2020-05-29 14:26:08 +03:00
for version in ${versions[@]}; do
modulePath="/usr/share/az_$version"
pwsh -Command "
\$env:PSModulePath = '${modulePath}:' + \$env:PSModulePath;
if ( -not (Get-Module -ListAvailable -Name Az.Accounts)) {
Write-Host 'Az Module was not installed'
exit 1
}"
if [ $? -ne 0 ]; then
echo "Az version $version is not installed"
exit 1
fi
done
2019-11-15 15:23:41 -05:00
# Document what was added to the image
echo "Lastly, documenting what we added to the metadata file"
2020-05-29 14:26:08 +03:00
for version in ${versions[@]}; do
DocumentInstalledItem "Az Module ($version)"
done