#!/bin/bash # disable warning about 'mkdir -m -p' # shellcheck disable=SC2174 set -Eeuxo pipefail printf "\n\tšŸ‹ Build started šŸ‹\t\n" # Remove '"' so it can be sourced by sh/bash sed 's|"||g' -i "/etc/environment" ImageOS=ubuntu$(echo "${FROM_TAG}" | cut -d'.' -f 1) AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache { echo "IMAGE_OS=$ImageOS" echo "ImageOS=$ImageOS" echo "LSB_RELEASE=${FROM_TAG}" echo "AGENT_TOOLSDIRECTORY=${AGENT_TOOLSDIRECTORY}" echo "RUN_TOOL_CACHE=${AGENT_TOOLSDIRECTORY}" echo "DEPLOYMENT_BASEPATH=/opt/runner" echo "USER=$(whoami)" echo "RUNNER_USER=$(whoami)" } | tee -a "/etc/environment" mkdir -m 0777 -p "${AGENT_TOOLSDIRECTORY}" chown -R 1001:1000 "${AGENT_TOOLSDIRECTORY}" mkdir -m 0777 -p /github chown -R 1001:1000 /github printf "\n\tšŸ‹ Installing packages šŸ‹\t\n" packages=( ssh lsb-release gawk curl git jq wget sudo gnupg-agent ca-certificates software-properties-common apt-transport-https libyaml-0-2 zstd zip unzip xz-utils ) apt-get -yq update apt-get -yq install --no-install-recommends --no-install-suggests "${packages[@]}" ln -s "$(which python3)" "/usr/local/bin/python" LSB_OS_VERSION=$(lsb_release -rs | sed 's|\.||g') echo "LSB_OS_VERSION=${LSB_OS_VERSION}" | tee -a "/etc/environment" wget -qO "/imagegeneration/toolset.json" "https://raw.githubusercontent.com/actions/virtual-environments/main/images/linux/toolsets/toolset-${LSB_OS_VERSION}.json" wget -qO "/imagegeneration/LICENSE" "https://raw.githubusercontent.com/actions/virtual-environments/main/LICENSE" ARCH=$(uname -m) if [ "$ARCH" = x86_64 ]; then ARCH=x64 wget -qO "/usr/bin/jq" "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64" chmod +x "/usr/bin/jq" fi if [ "$ARCH" = aarch64 ]; then ARCH=arm64; fi if [[ "${FROM_TAG}" == "16.04" ]]; then printf 'git-lfs not available for Xenial' else apt-get -yq install --no-install-recommends --no-install-suggests git-lfs fi printf "\n\tšŸ‹ Updated apt lists and upgraded packages šŸ‹\t\n" printf "\n\tšŸ‹ Creating ~/.ssh and adding 'github.com' šŸ‹\t\n" mkdir -m 0700 -p ~/.ssh { ssh-keyscan -t rsa github.com ssh-keyscan -t rsa ssh.dev.azure.com } >>/etc/ssh/ssh_known_hosts printf "\n\tšŸ‹ Installed base utils šŸ‹\t\n" printf "\n\tšŸ‹ Installing docker cli šŸ‹\t\n" curl "https://packages.microsoft.com/config/ubuntu/${FROM_TAG}/prod.list" | tee /etc/apt/sources.list.d/microsoft-prod.list wget -q https://packages.microsoft.com/keys/microsoft.asc gpg --dearmor /etc/apt/trusted.gpg.d/microsoft.gpg apt-key add -