From b6e1216543414017858fd7aa91cf4272db8bdd75 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev <50947177+Darleev@users.noreply.github.com> Date: Tue, 27 Oct 2020 17:16:55 +0700 Subject: [PATCH] [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 --- images/linux/scripts/base/apt.sh | 12 +++++++++++- images/linux/scripts/installers/azpowershell.sh | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/images/linux/scripts/base/apt.sh b/images/linux/scripts/base/apt.sh index 8afcbe8d..ff1a9271 100644 --- a/images/linux/scripts/base/apt.sh +++ b/images/linux/scripts/base/apt.sh @@ -3,11 +3,21 @@ export DEBIAN_FRONTEND=noninteractive apt-get -yq update apt-get -yq dist-upgrade -systemctl disable apt-daily.service + +# Stop and disable apt-daily upgrade services; +systemctl stop apt-daily.timer systemctl disable apt-daily.timer +systemctl disable apt-daily.service +systemctl stop apt-daily-upgrade.timer systemctl disable apt-daily-upgrade.timer systemctl disable apt-daily-upgrade.service +# This step should completely disable any automatic updates except manual +sudo sed -i 's/APT::Periodic::Update-Package-Lists "1"/APT::Periodic::Update-Package-Lists "0"/' /etc/apt/apt.conf.d/20auto-upgrades + +# Enable retry logic for apt up to 10 times +echo "APT::Acquire::Retries \"10\";" > /etc/apt/apt.conf.d/80-retries + # Configure apt to always assume Y echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes diff --git a/images/linux/scripts/installers/azpowershell.sh b/images/linux/scripts/installers/azpowershell.sh index a8488af7..47ac5ff3 100644 --- a/images/linux/scripts/installers/azpowershell.sh +++ b/images/linux/scripts/installers/azpowershell.sh @@ -15,9 +15,13 @@ else 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" + 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