From cebf52206b92f7a875e68e4b9c376bcde9b38b8e Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev Date: Wed, 8 Jul 2020 15:34:53 +0300 Subject: [PATCH 1/3] remove source apt.sh --- images/linux/scripts/helpers/containercache.sh | 1 - images/linux/scripts/installers/1604/android.sh | 1 - images/linux/scripts/installers/1604/basic.sh | 1 - images/linux/scripts/installers/1804/android.sh | 1 - images/linux/scripts/installers/aliyun-cli.sh | 1 - images/linux/scripts/installers/basic.sh | 1 - images/linux/scripts/installers/build-essential.sh | 1 - images/linux/scripts/installers/clang.sh | 1 - images/linux/scripts/installers/containers.sh | 1 - images/linux/scripts/installers/docker-compose.sh | 1 - images/linux/scripts/installers/docker-moby.sh | 1 - images/linux/scripts/installers/dotnetcore-sdk.sh | 1 - images/linux/scripts/installers/erlang.sh | 1 - images/linux/scripts/installers/example.sh | 1 - images/linux/scripts/installers/firefox.sh | 1 - images/linux/scripts/installers/heroku.sh | 1 - images/linux/scripts/installers/hhvm.sh | 1 - images/linux/scripts/installers/image-magick.sh | 1 - images/linux/scripts/installers/kubernetes-tools.sh | 1 - images/linux/scripts/installers/mercurial.sh | 1 - images/linux/scripts/installers/packer.sh | 1 - images/linux/scripts/installers/terraform.sh | 1 - 22 files changed, 22 deletions(-) diff --git a/images/linux/scripts/helpers/containercache.sh b/images/linux/scripts/helpers/containercache.sh index b4e389a7a..018bcf534 100644 --- a/images/linux/scripts/helpers/containercache.sh +++ b/images/linux/scripts/helpers/containercache.sh @@ -4,7 +4,6 @@ ## Desc: Prepulls Docker images used in build tasks and templates ################################################################################ -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh # Check prereqs diff --git a/images/linux/scripts/installers/1604/android.sh b/images/linux/scripts/installers/1604/android.sh index 3d40984ba..e3b33e064 100644 --- a/images/linux/scripts/installers/1604/android.sh +++ b/images/linux/scripts/installers/1604/android.sh @@ -8,7 +8,6 @@ set -e # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Set env variable for SDK Root (https://developer.android.com/studio/command-line/variables) ANDROID_ROOT=/usr/local/lib/android diff --git a/images/linux/scripts/installers/1604/basic.sh b/images/linux/scripts/installers/1604/basic.sh index cd4017140..2abfda60c 100644 --- a/images/linux/scripts/installers/1604/basic.sh +++ b/images/linux/scripts/installers/1604/basic.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh set -e diff --git a/images/linux/scripts/installers/1804/android.sh b/images/linux/scripts/installers/1804/android.sh index 0effcaca3..0040049ea 100644 --- a/images/linux/scripts/installers/1804/android.sh +++ b/images/linux/scripts/installers/1804/android.sh @@ -8,7 +8,6 @@ set -e # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Set env variable for SDK Root (https://developer.android.com/studio/command-line/variables) ANDROID_ROOT=/usr/local/lib/android diff --git a/images/linux/scripts/installers/aliyun-cli.sh b/images/linux/scripts/installers/aliyun-cli.sh index 0f44110df..ed826c90e 100644 --- a/images/linux/scripts/installers/aliyun-cli.sh +++ b/images/linux/scripts/installers/aliyun-cli.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Install Alibaba Cloud CLI URL=$(curl -s https://api.github.com/repos/aliyun/aliyun-cli/releases/latest | jq -r '.assets[].browser_download_url | select(contains("aliyun-cli-linux"))') diff --git a/images/linux/scripts/installers/basic.sh b/images/linux/scripts/installers/basic.sh index cef98a9f4..3caf0d060 100644 --- a/images/linux/scripts/installers/basic.sh +++ b/images/linux/scripts/installers/basic.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/os.sh set -e diff --git a/images/linux/scripts/installers/build-essential.sh b/images/linux/scripts/installers/build-essential.sh index 70ea94042..0c98e42cd 100644 --- a/images/linux/scripts/installers/build-essential.sh +++ b/images/linux/scripts/installers/build-essential.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh PACKAGE=build-essential diff --git a/images/linux/scripts/installers/clang.sh b/images/linux/scripts/installers/clang.sh index 631be1909..eb508493b 100644 --- a/images/linux/scripts/installers/clang.sh +++ b/images/linux/scripts/installers/clang.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh function InstallClang { version=$1 diff --git a/images/linux/scripts/installers/containers.sh b/images/linux/scripts/installers/containers.sh index 547707e2e..77e542286 100644 --- a/images/linux/scripts/installers/containers.sh +++ b/images/linux/scripts/installers/containers.sh @@ -4,7 +4,6 @@ ## Desc: Installs container tools: podman, buildah and skopeo onto the image ################################################################################ -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh source /etc/os-release diff --git a/images/linux/scripts/installers/docker-compose.sh b/images/linux/scripts/installers/docker-compose.sh index 688928f0e..76a5df7b9 100644 --- a/images/linux/scripts/installers/docker-compose.sh +++ b/images/linux/scripts/installers/docker-compose.sh @@ -4,7 +4,6 @@ ## Desc: Installs Docker Compose ################################################################################ -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh URL=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[].browser_download_url | select(contains("docker-compose-Linux-x86_64"))' | head -1) diff --git a/images/linux/scripts/installers/docker-moby.sh b/images/linux/scripts/installers/docker-moby.sh index 1037b2204..f5cb8ef3a 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -4,7 +4,6 @@ ## Desc: Installs docker onto the image ################################################################################ -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh source $HELPER_SCRIPTS/os.sh diff --git a/images/linux/scripts/installers/dotnetcore-sdk.sh b/images/linux/scripts/installers/dotnetcore-sdk.sh index 0544875b4..8c1006ea2 100644 --- a/images/linux/scripts/installers/dotnetcore-sdk.sh +++ b/images/linux/scripts/installers/dotnetcore-sdk.sh @@ -4,7 +4,6 @@ ## Desc: Installs .NET Core SDK ################################################################################ source $HELPER_SCRIPTS/etc-environment.sh -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh source $HELPER_SCRIPTS/os.sh diff --git a/images/linux/scripts/installers/erlang.sh b/images/linux/scripts/installers/erlang.sh index f71c6de45..31a3a3061 100644 --- a/images/linux/scripts/installers/erlang.sh +++ b/images/linux/scripts/installers/erlang.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh source_list=/etc/apt/sources.list.d/eslerlang.list diff --git a/images/linux/scripts/installers/example.sh b/images/linux/scripts/installers/example.sh index a4937447c..d0f3c5c3d 100644 --- a/images/linux/scripts/installers/example.sh +++ b/images/linux/scripts/installers/example.sh @@ -7,7 +7,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Test to see if the software in question is already installed, if not install it echo "Checking to see if the installer script has already been run" diff --git a/images/linux/scripts/installers/firefox.sh b/images/linux/scripts/installers/firefox.sh index e6e28afd8..76613da23 100644 --- a/images/linux/scripts/installers/firefox.sh +++ b/images/linux/scripts/installers/firefox.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Install Firefox apt-get install -y firefox diff --git a/images/linux/scripts/installers/heroku.sh b/images/linux/scripts/installers/heroku.sh index 3bcbc590f..ff39be66c 100644 --- a/images/linux/scripts/installers/heroku.sh +++ b/images/linux/scripts/installers/heroku.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Install Heroku CLI curl https://cli-assets.heroku.com/install-ubuntu.sh | sh diff --git a/images/linux/scripts/installers/hhvm.sh b/images/linux/scripts/installers/hhvm.sh index 10d42dae6..e27d40e21 100644 --- a/images/linux/scripts/installers/hhvm.sh +++ b/images/linux/scripts/installers/hhvm.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh hhvm_package=hhvm diff --git a/images/linux/scripts/installers/image-magick.sh b/images/linux/scripts/installers/image-magick.sh index bfeee5a05..39925fdfe 100644 --- a/images/linux/scripts/installers/image-magick.sh +++ b/images/linux/scripts/installers/image-magick.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Install ImageMagick apt-get install -y --no-install-recommends --fix-missing \ diff --git a/images/linux/scripts/installers/kubernetes-tools.sh b/images/linux/scripts/installers/kubernetes-tools.sh index 0503b8503..8512b68c4 100644 --- a/images/linux/scripts/installers/kubernetes-tools.sh +++ b/images/linux/scripts/installers/kubernetes-tools.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh ## Install kubectl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - diff --git a/images/linux/scripts/installers/mercurial.sh b/images/linux/scripts/installers/mercurial.sh index 77e5bc857..af40bf817 100644 --- a/images/linux/scripts/installers/mercurial.sh +++ b/images/linux/scripts/installers/mercurial.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/os.sh if isUbuntu16 ; then diff --git a/images/linux/scripts/installers/packer.sh b/images/linux/scripts/installers/packer.sh index cba8dfb7b..d44dd9c02 100644 --- a/images/linux/scripts/installers/packer.sh +++ b/images/linux/scripts/installers/packer.sh @@ -5,7 +5,6 @@ ################################################################################ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Install Packer PACKER_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r .current_version) diff --git a/images/linux/scripts/installers/terraform.sh b/images/linux/scripts/installers/terraform.sh index be811473a..8cbd026a0 100644 --- a/images/linux/scripts/installers/terraform.sh +++ b/images/linux/scripts/installers/terraform.sh @@ -6,7 +6,6 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh # Install Terraform TERRAFORM_VERSION=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r .current_version) From a7ee8ab67223245e21165f99ce7cff8adc881780 Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev Date: Wed, 8 Jul 2020 22:28:23 +0300 Subject: [PATCH 2/3] move IsInstalled and apt-fast --- images/linux/scripts/base/apt.sh | 13 +++++++++-- images/linux/scripts/helpers/apt.sh | 23 ------------------- images/linux/scripts/helpers/install.sh | 9 ++++++++ .../scripts/installers/build-essential.sh | 1 + .../linux/scripts/installers/docker-moby.sh | 1 + .../scripts/installers/dotnetcore-sdk.sh | 2 ++ images/linux/scripts/installers/hhvm.sh | 1 + 7 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 images/linux/scripts/helpers/apt.sh diff --git a/images/linux/scripts/base/apt.sh b/images/linux/scripts/base/apt.sh index 15307421f..b7ad9e7bb 100644 --- a/images/linux/scripts/base/apt.sh +++ b/images/linux/scripts/base/apt.sh @@ -1,9 +1,18 @@ #!/bin/bash export DEBIAN_FRONTEND=noninteractive -apt-get -yqq update -apt-get -yqq dist-upgrade +apt-get -yq update +apt-get -yq dist-upgrade systemctl disable apt-daily.service systemctl disable apt-daily.timer systemctl disable apt-daily-upgrade.timer systemctl disable apt-daily-upgrade.service + +# Configure apt to always assume Y +echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes + +# Use apt-fast for parallel downloads +apt-get install aria2 +add-apt-repository -y ppa:apt-fast/stable +apt-get update +apt-get -y install apt-fast diff --git a/images/linux/scripts/helpers/apt.sh b/images/linux/scripts/helpers/apt.sh deleted file mode 100644 index e95a2160f..000000000 --- a/images/linux/scripts/helpers/apt.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -################################################################################ -## File: apt.sh -## Desc: This script contains helper functions for using dpkg and apt -################################################################################ - -## Use dpkg to figure out if a package has already been installed -## Example use: -## if ! IsInstalled packageName; then -## echo "packageName is not installed!" -## fi -function IsInstalled { - dpkg -S $1 &> /dev/null -} - -# Configure apt to always assume Y -echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes - -# Use apt-fast for parallel downloads -apt-get install aria2 -add-apt-repository -y ppa:apt-fast/stable -apt-get update -apt-get -y install apt-fast diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index 0843983ed..e5cb08006 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -33,4 +33,13 @@ download_with_retries() { echo "Could not download $URL" return 1 +} + +## Use dpkg to figure out if a package has already been installed +## Example use: +## if ! IsInstalled packageName; then +## echo "packageName is not installed!" +## fi +function IsInstalled { + dpkg -S $1 &> /dev/null } \ No newline at end of file diff --git a/images/linux/scripts/installers/build-essential.sh b/images/linux/scripts/installers/build-essential.sh index 0c98e42cd..f84e5857b 100644 --- a/images/linux/scripts/installers/build-essential.sh +++ b/images/linux/scripts/installers/build-essential.sh @@ -6,6 +6,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh PACKAGE=build-essential diff --git a/images/linux/scripts/installers/docker-moby.sh b/images/linux/scripts/installers/docker-moby.sh index f5cb8ef3a..8ee78a8c0 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -5,6 +5,7 @@ ################################################################################ source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh docker_package=moby diff --git a/images/linux/scripts/installers/dotnetcore-sdk.sh b/images/linux/scripts/installers/dotnetcore-sdk.sh index 8c1006ea2..0cd324fe4 100644 --- a/images/linux/scripts/installers/dotnetcore-sdk.sh +++ b/images/linux/scripts/installers/dotnetcore-sdk.sh @@ -3,8 +3,10 @@ ## File: dotnetcore-sdk.sh ## Desc: Installs .NET Core SDK ################################################################################ + source $HELPER_SCRIPTS/etc-environment.sh source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh # Ubuntu 20 doesn't support EOL versions diff --git a/images/linux/scripts/installers/hhvm.sh b/images/linux/scripts/installers/hhvm.sh index e27d40e21..97c5c7b1e 100644 --- a/images/linux/scripts/installers/hhvm.sh +++ b/images/linux/scripts/installers/hhvm.sh @@ -6,6 +6,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh hhvm_package=hhvm From 0647236ac1514815b1795a6b373b409cb3ab22ba Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev Date: Thu, 9 Jul 2020 15:14:28 +0300 Subject: [PATCH 3/3] Rename IsIntalled -> IsPackageInstalled --- images/linux/scripts/helpers/install.sh | 4 ++-- images/linux/scripts/installers/build-essential.sh | 2 +- images/linux/scripts/installers/docker-moby.sh | 2 +- images/linux/scripts/installers/dotnetcore-sdk.sh | 2 +- images/linux/scripts/installers/hhvm.sh | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index e5cb08006..0f90ac4ae 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -37,9 +37,9 @@ download_with_retries() { ## Use dpkg to figure out if a package has already been installed ## Example use: -## if ! IsInstalled packageName; then +## if ! IsPackageInstalled packageName; then ## echo "packageName is not installed!" ## fi -function IsInstalled { +function IsPackageInstalled { dpkg -S $1 &> /dev/null } \ No newline at end of file diff --git a/images/linux/scripts/installers/build-essential.sh b/images/linux/scripts/installers/build-essential.sh index f84e5857b..34c2ac040 100644 --- a/images/linux/scripts/installers/build-essential.sh +++ b/images/linux/scripts/installers/build-essential.sh @@ -12,7 +12,7 @@ PACKAGE=build-essential # Test to see if the software in question is already installed, if not install it echo "Checking to see if the installer script has already been run" -if ! IsInstalled $PACKAGE; then +if ! IsPackageInstalled $PACKAGE; then echo "Installing $PACKAGE" apt-get install -y --no-install-recommends $PACKAGE else diff --git a/images/linux/scripts/installers/docker-moby.sh b/images/linux/scripts/installers/docker-moby.sh index 8ee78a8c0..9b55e764c 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -17,7 +17,7 @@ fi ## Check to see if docker is already installed echo "Determing if Docker ($docker_package) is installed" -if ! IsInstalled $docker_package; then +if ! IsPackageInstalled $docker_package; then echo "Docker ($docker_package) was not found. Installing..." apt-get remove -y moby-engine moby-cli apt-get update diff --git a/images/linux/scripts/installers/dotnetcore-sdk.sh b/images/linux/scripts/installers/dotnetcore-sdk.sh index 0cd324fe4..c74c34be1 100644 --- a/images/linux/scripts/installers/dotnetcore-sdk.sh +++ b/images/linux/scripts/installers/dotnetcore-sdk.sh @@ -44,7 +44,7 @@ export DOTNET_CLI_TELEMETRY_OPTOUT=1 for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do echo "Determing if .NET Core ($latest_package) is installed" - if ! IsInstalled $latest_package; then + if ! IsPackageInstalled $latest_package; then echo "Could not find .NET Core ($latest_package), installing..." apt-get install $latest_package -y else diff --git a/images/linux/scripts/installers/hhvm.sh b/images/linux/scripts/installers/hhvm.sh index 97c5c7b1e..e5f9079bc 100644 --- a/images/linux/scripts/installers/hhvm.sh +++ b/images/linux/scripts/installers/hhvm.sh @@ -12,7 +12,7 @@ hhvm_package=hhvm # Test to see if the software in question is already installed, if not install it echo "Checking to see if the installer script has already been run" -if ! IsInstalled ${hhvm_package}; then +if ! IsPackageInstalled ${hhvm_package}; then apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xB4112585D386EB94 add-apt-repository https://dl.hhvm.com/ubuntu apt-get update @@ -23,7 +23,7 @@ fi # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" -if ! IsInstalled ${hhvm_package}; then +if ! IsPackageInstalled ${hhvm_package}; then echo "${hhvm_package} was not installed" exit 1 fi