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/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/helpers/install.sh b/images/linux/scripts/helpers/install.sh index c61c2431d..232a7353d 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 ! IsPackageInstalled packageName; then +## echo "packageName is not installed!" +## fi +function IsPackageInstalled { + dpkg -S $1 &> /dev/null } \ No newline at end of file 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/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 de55d67dc..b6bd53770 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..34c2ac040 100644 --- a/images/linux/scripts/installers/build-essential.sh +++ b/images/linux/scripts/installers/build-essential.sh @@ -6,13 +6,13 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh +source $HELPER_SCRIPTS/install.sh 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/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..9b55e764c 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -4,8 +4,8 @@ ## Desc: Installs docker onto the image ################################################################################ -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh docker_package=moby @@ -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 0544875b4..c74c34be1 100644 --- a/images/linux/scripts/installers/dotnetcore-sdk.sh +++ b/images/linux/scripts/installers/dotnetcore-sdk.sh @@ -3,9 +3,10 @@ ## File: dotnetcore-sdk.sh ## Desc: Installs .NET Core SDK ################################################################################ + source $HELPER_SCRIPTS/etc-environment.sh -source $HELPER_SCRIPTS/apt.sh source $HELPER_SCRIPTS/document.sh +source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh # Ubuntu 20 doesn't support EOL versions @@ -43,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/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..e5f9079bc 100644 --- a/images/linux/scripts/installers/hhvm.sh +++ b/images/linux/scripts/installers/hhvm.sh @@ -6,13 +6,13 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh -source $HELPER_SCRIPTS/apt.sh +source $HELPER_SCRIPTS/install.sh 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 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)