Hari Sekhon 5 years ago
commit c9523b3a9d

@ -85,11 +85,11 @@ alias tmp="cd /tmp"
#fi
# shellcheck disable=SC2139
alias bt="cd $(dirname "${BASH_SOURCE[0]}")/.."
alias bt="sti bt; cd $(dirname "${BASH_SOURCE[0]}")/.."
# shellcheck disable=SC2154
export bashd="$bash_tools/.bash.d"
alias bashd='cd $bashd'
alias bashd='sti bashd; cd $bashd'
#alias cleanshell='exec env - bash --rcfile /dev/null'
alias cleanshell='exec env - bash --norc --noprofile'

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
# shellcheck disable=SC1090
#
# Author: Hari Sekhon
# Date: 2019-11-14 22:22:35 +0000 (Thu, 14 Nov 2019)
#
# https://github.com/harisekhon/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 - G o o g l e C l o u d P l a t f o r m
# ============================================================================ #
srcdir="${srcdir:-$(dirname "${BASH_SOURCE[0]}")/..}"
# shellcheck disable=SC1090
type add_PATH &>/dev/null || . "$srcdir/.bash.d/paths.sh"
# adds GCloud CLI tools to $PATH
if [ -f ~/google-cloud-sdk/path.bash.inc ]; then
source ~/google-cloud-sdk/path.bash.inc
fi
# Bash completion for GCloud CLI tools
if [ -f ~/google-cloud-sdk/completion.bash.inc ]; then
source ~/google-cloud-sdk/completion.bash.inc
fi

7
.gitignore vendored

@ -10,6 +10,10 @@
#
# to check that there aren't some legit files you need to commit
# To find out which line is causing a given file to be ignored, do:
#
# git check-ignore -v $filename
*.avi
*.bak
*.bak.*
@ -559,7 +563,8 @@ fabric.properties
### C ###
# Prerequisites
*.d
# XXX: clashes with .bash.d/* and .conf.d/* type stuff
#*.d
# Object files
*.o

@ -4,7 +4,7 @@
"
" ============================================================================ "
" v i m r c
" v i m r c
" ============================================================================ "
" to reload without restarting vim

@ -47,6 +47,8 @@ define MAKEFILE_USAGE
make ccmenu installs and (re)configures CCMenu to watch this all other major HariSekhon repos
make aws installs AWS CLI
make gcp installs GCloud SDK
endef
.PHONY: build
@ -138,6 +140,10 @@ python-desktop: system-packages
aws: system-packages
@./python_pip_install_if_absent.sh awscli
.PHONY: gcp
gcp: system-packages
@./setup/install_gcloud.sh
.PHONY: test
test:
./check_all.sh

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2128,SC2230
# shellcheck disable=SC2128,SC2230,SC1090
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
@ -23,12 +23,8 @@ if [ "${bash_tools_utils_imported:-0}" = 1 ]; then
fi
bash_tools_utils_imported=1
# shellcheck disable=SC1090
. "$srcdir_bash_tools_utils/docker.sh"
# shellcheck disable=SC1090
. "$srcdir_bash_tools_utils/perl.sh"
. "$srcdir_bash_tools_utils/../.bash.d/colors.sh"
# consider adding ERR as set -e handler, not inherited by shell funcs / cmd substitutions / subshells without set -E
@ -42,7 +38,11 @@ if [ -z "${total_run_count:-}" ]; then
fi
# ERE format (egrep / grep -E)
#
# used in client scripts
# shellcheck disable=SC2034
domain_regex='\b(([A-Za-z](-?[A-Za-z0-9])*)\.)+[A-Za-z]{2,}\b'
# shellcheck disable=SC2034
email_regex='\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b'
wrong_port=1111
@ -157,6 +157,8 @@ check_exit_code(){
}
tick_msg(){
# defined in .bash.d/colors.sh
# shellcheck disable=SC2154
echo -e "${bldgrn}${txtrst}$*"
}

@ -0,0 +1,97 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2019-11-14 20:56:43 +0000 (Thu, 14 Nov 2019)
#
# https://github.com/harisekhon/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
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
#apt_version="123.0.0-0"
#yum_version="123.0.0"
# installs to $HOME/google-cloud-sdk
install_root_dir="$HOME"
apt_optional_packages="
google-cloud-sdk-app-engine-python \
google-cloud-sdk-app-engine-python-extras \
google-cloud-sdk-app-engine-java \
google-cloud-sdk-app-engine-go \
google-cloud-sdk-datalab \
google-cloud-sdk-datastore-emulator \
google-cloud-sdk-pubsub-emulator \
google-cloud-sdk-cbt \
google-cloud-sdk-cloud-build-local \
google-cloud-sdk-bigtable-emulator \
kubectl
"
yum_optional_packages="
google-cloud-sdk-app-engine-python
google-cloud-sdk-app-engine-python-extras
google-cloud-sdk-app-engine-java
google-cloud-sdk-app-engine-go
google-cloud-sdk-bigtable-emulator
google-cloud-sdk-datalab
google-cloud-sdk-datastore-emulator
google-cloud-sdk-cbt
google-cloud-sdk-cloud-build-local
google-cloud-sdk-pubsub-emulator
kubectl
"
sudo=sudo
[ $EUID -eq 0 ] && sudo=""
echo "Installing Google Cloud SDK"
if type -P yum &>/dev/null; then
$sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOF
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install -y google-cloud-sdk #-$yum_version
# want splitting to single line
# shellcheck disable=SC2086
yum install -y $yum_optional_packages
# https://cloud.google.com/sdk/docs/downloads-apt-get
elif type -P apt-get &>/dev/null; then
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | $sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
$sudo apt-get install -y apt-transport-https ca-certificates
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | $sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
$sudo apt-get update
$sudo apt-get install -y google-cloud-sdk #=$apt_version
# want splitting to single line
# shellcheck disable=SC2086
$sudo apt-get install -y $apt_optional_packages
elif [[ "$(uname -s)" =~ Darwin|Linux ]]; then
# https://cloud.google.com/sdk/docs/downloads-interactive
install_script="$(mktemp -t gcloud_installer.sh.XXXXXX)"
curl https://sdk.cloud.google.com > "$install_script"
chmod +x "$install_script"
"$install_script" --disable-prompts --install-dir="$install_root_dir"
else
echo "Unsupported OS '$(uname -s)'" >&2
exit 1
fi
# requires interactive prompts
#echo "Initializing gcloud..."
#gcloud init
echo
echo "Done. You will need to run 'gcloud init' to set up your profile."

@ -23,7 +23,7 @@ conf_files="$(sed 's/#.*//; /^[[:space:]]*$/d' "$srcdir/setup/files.conf")"
setup_file(){
local filename="$1"
if grep -Eq "^[[:space:]]*(source|\.)[[:space:]]+$srcdir/$filename" ~/"$filename" 2>/dev/null; then
if grep -Eq "^[[:space:]]*(source|\\.)[[:space:]]+$srcdir/$filename" ~/"$filename" 2>/dev/null; then
echo "$filename already sourced in ~/$filename"
else
echo "injecting into ~/$filename: source $srcdir/$filename"

@ -38,7 +38,9 @@ remove_sourcing(){
echo "$filename not currently sourced in ~/$filename"
else
echo "in-place editing ~/$filename to remove sourcing of $srcdir/$filename"
perl -ni".bak-$(date '+%F_%H%M')" -e "print unless /(source|\\.)[[:space:]]+${srcdir//\//\\/}\/${filename//\//\\/}/" ~/"$filename"
local srcdir_escaped="${srcdir//\//\\/}"
local filename_escaped="${filename//\//\\/}"
perl -ni".bak-$(date '+%F_%H%M')" -e "print unless /(source|\\.)[[:space:]]+$srcdir_escaped\\/$filename_escaped/" ~/"$filename"
fi
}

Loading…
Cancel
Save