#!/usr/bin/env bash
#  vim:ts=4:sts=4:sw=4:et
#
#  Author: Hari Sekhon
#  Date: 2019-11-19 16:43:00 +0000 (Tue, 19 Nov 2019)
#
#  https://github.com/HariSekhon/DevOps-Bash-tools
#
#  License: see accompanying Hari Sekhon LICENSE file
#
#  If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
#  https://www.linkedin.com/in/HariSekhon
#

# ============================================================================ #
#           G C P   C l o u d   S h e l l   C u s t o m i z a t i o n
# ============================================================================ #

# see log at /var/log/customize_environment

# /google/devshell/customize_environment_done is touched when completed

# called as root by GCP

set -euxo pipefail

bash_tools="$HOME/github/bash-tools"

if ! [ -d "$bash_tools" ]; then
    parent_dir="${bash_tools%/*}"
    mkdir -pv "$parent_dir"
    pushd "$parent_dir"
    git clone https://github.com/HariSekhon/DevOps-Bash-tools "$bash_tools"
    popd
fi

mkdir -pv ~/.cloudshell

# suppress apt-get warnings about being ephemeral, that is what this script is for
touch ~/.cloudshell/no-apt-get-warning

pushd "$bash_tools"

git pull

# not calling gcp-shell which also links because it will link config files to /root
# instead just run 'make gcp-shell' one time to set up $USER's $HOME
make system-packages

popd
