Files
runner-images/images/linux/scripts/installers/azpowershell.sh
Darii Nurgaleev b6e1216543 [ubuntu] Disable automatic updates to avoid apt lock issue. (#1761)
* added shutdown-apt-service.sh script

* added logging

* added new status

* shutdown service check

* removed apy.daily from apt.sh

* Another way to disable automatic updates;

* fix deployment files.

* enable retry logic for apt

* add PowerShellGet installation before az modules

* fixed a comment

Co-authored-by: Leonid Lapshin <originalnoe-nazvanie@yandex.ru>
2020-10-27 13:16:55 +03:00

42 lines
1.6 KiB
Bash

#!/bin/bash -e
################################################################################
## File: azpowershell.sh
## Desc: Installed Azure PowerShell
################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
# List of versions
if isUbuntu20 ; then
versions=$(pwsh -Command '(Find-Module -Name Az).Version')
else
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
versions=$(jq -r '.azureModules[] | select(.name | contains("az")) | .versions[]' $toolset)
fi
# Try to install and update PowerShellGet before the actual installation
pwsh -Command "Install-Module -Name PowerShellGet -Force"
pwsh -Command "Update-Module -Name PowerShellGet -Force"
# Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
for version in ${versions[@]}; do
pwsh -Command "Save-Module -Name Az -LiteralPath /usr/share/az_$version -RequiredVersion $version -Force -Verbose"
done
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
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