Add gcloud installation script

This commit is contained in:
Andrejs Cunskis 2022-04-28 18:07:39 +03:00
parent be7af7d540
commit a0317aa98d
No known key found for this signature in database
GPG key ID: 87CB75083F227241

27
scripts/install-gcloud Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
set -xeuo pipefail
export DEBIAN_FRONTEND=noninteractive
GCLOUD_VERSION=${1}
apt-get update
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
python3 \
gnupg
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
apt-get update
PACKAGE_VERSION=$(apt-cache policy google-cloud-cli | awk -v dv=${GCLOUD_VERSION} '$1 ~ dv {print $1}')
apt-get install -y google-cloud-cli=${PACKAGE_VERSION}
apt-get -yq autoremove
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*