diff --git a/.env-gdc b/.env-gdc index 5fe6934..ff4fdc0 100644 --- a/.env-gdc +++ b/.env-gdc @@ -11,6 +11,10 @@ fi export USE_HOST_HOME=${USE_HOST_HOME:=yes} # mount home directory from host +if [ -z ${SHOW_VERSIONS_ON_LOGIN+x} ]; then + export SHOW_VERSIONS_ON_LOGIN=yes # show installed versions on each login +fi + if [ -z ${TERRAFORM_VERSION+x} ]; then export TERRAFORM_VERSION=latest # install this version of terraform by default fi diff --git a/docker-compose.yml b/docker-compose.yml index 309bdfc..17d6fc8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,6 +47,7 @@ services: - EDITOR # sets default editor in container. usually set to same as VISUAL - VISUAL # sets default editor in container. usually set to same as EDITOR - USE_COLOR_PROMPT # enable colored bash prompt + - SHOW_VERSIONS_ON_LOGIN # show versions of installed tools on login - SSH_SERVER_PORT # host port you want forwarded to ssh server in container - SSH_KEYSCAN_HOSTS # copy ssh keys from these hosts to prevent unknown key prompts - USE_AUTH0 # starts up auth0 mock container in container only mode @@ -107,7 +108,7 @@ services: - STARTUP_MSG # message to display after startup - CLIPBOARD_MSG # used internally to show message about launch command copied to clipboard - COMPOSE_BIN # used to toggle between docker-compose and docker compose invocations - - COPY_CMD_TO_CLIPBOARD # defaults to yes to copy gdc shell launch command to clipboard + - COPY_CMD_TO_CLIPBOARD # defaults to yes to copy gdc shell-launch command to clipboard - HOST_PROJECT_REL_PATH # Project path on host relative to GDC repository - USE_PROXY # can be no/proxy/dump/web. defaults to no - USE_PROXY_HOST # can be no/yes. defaults to no @@ -120,7 +121,7 @@ services: - PROXY_URL # http proxy to use. if USE_PROXY_HOST is enabled will be set to http://PROXY_CONTAINER_NAME:8080 - PROXY_URL_SSL # https proxy to use. if USE_PROXY_HOST is enabled will be set to https://PROXY_CONTAINER_NAME:8080 - PROXY_AUTO_EXPORT_ENV # auto export HTTP_PROXY and HTTPS_PROXY vars equal to PROXY_URL - - DEV_CONTAINER=1.10.4 # used to detect if running inside dev container + - DEV_CONTAINER=1.10.5 # used to detect if running inside dev container volumes: - /var/run/docker.sock:/var/run/docker.sock # allow container to interact with host docker - "${GDC_DIR}:/root/gdc-host" # mount gdc folder inside container to get access to compose files diff --git a/etc/skel/.bashrc b/etc/skel/.bashrc index 1a3b284..b3fd545 100644 --- a/etc/skel/.bashrc +++ b/etc/skel/.bashrc @@ -1,7 +1,3 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - if [ "$FORCE_INTERACTIVE" != "yes" ]; then # If not running interactively, don't do anything case $- in @@ -91,10 +87,6 @@ alias l='ls -CF' alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' # Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - if [ -f ~/.bash_aliases ]; then . "$HOME/.bash_aliases" fi @@ -132,41 +124,63 @@ fi TITLE="GDC: $COMPOSE_PROJECT_NAME shell" echo -n -e "$title_start$TITLE$title_end" -docker --version +if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + docker --version +fi if [ -n "$PHP_VERSION" ]; then - echo "php version $(php --version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "php version $(php --version)" + fi fi if [ "$USE_DOT_NET" = "yes" ]; then - echo ".NET version $(dotnet --list-sdks)" export DOTNET_ROOT=/usr/local/dotnet export PATH=${PATH}:${DOTNET_ROOT} + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo ".NET version $(dotnet --list-sdks)" + fi fi if [ -n "$GOLANG_VERSION" ]; then export GOPATH=/go export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin - go version + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + go version + fi fi if [ -r "$NVM_DIR/nvm.sh" ]; then echo "activating nvm env" . "$NVM_DIR/nvm.sh" - echo "node version $(node --version)" - echo "npm version $(npm --version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "node version $(node --version)" + echo "npm version $(npm --version)" + fi fi if [ "$USE_BITWARDEN" = "yes" ]; then - echo "bitwarden cli version $(bw --version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "bitwarden cli version $(bw --version)" + fi alias load_aliases="eval \`bw get item aws_bash_rc | jq -r '.notes'\`" alias bw_reload="bw sync; load_aliases" if [ "$PERSIST_BITWARDEN_SESSION" = "yes" ]; then - alias unlock='export BW_SESSION="$(bw unlock --raw)"; bw sync; load_aliases; echo "export BW_SESSION=$BW_SESSION;load_aliases">/root/persisted/.bw_session' + alias unlock='export BW_SESSION="$(bw unlock --raw)"; bw sync; load_aliases; echo "export BW_SESSION=$BW_SESSION">/root/persisted/.bw_session' if [ -r ~/persisted/.bw_session ]; then - echo "loading existing bitwarden session" + echo "Attempting to load existing bitwarden session..." . "$HOME/persisted/.bw_session" + bw get item aws_bash_rc --nointeraction --quiet + if [ $? -ne 0 ] ; then + echo -e $bldred"Existing session invalid$txtrst. Please run '$bldgrn""unlock$txtrst'" + rm -f ~/persisted/.bw_session + bw sync --nointeraction --quiet + else + eval `bw get item aws_bash_rc | jq -r '.notes'` + fi + else + echo -e $bldylw"No existing bitwarden session found$txtrst. Please run '$bldgrn""unlock$txtrst'" fi else alias unlock='export BW_SESSION="$(bw unlock --raw)"; bw sync; load_aliases; echo "export BW_SESSION=$BW_SESSION;load_aliases"' @@ -183,13 +197,17 @@ if [ "$USE_AWS" = "yes" ]; then if [ ! -r ~/.aws/config ]; then echo "**** No AWS credentials found, run setup-aws.sh to configure ****" fi - echo "aws cli version $(aws --version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "aws cli version $(aws --version)" + fi fi if [ "$USE_CDK" = "yes" ]; then + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then echo "cdk version $(cdk --version)" echo "terraform version $(terraform -version)" echo "cdktf version $(cdktf --version)" + fi fi if [ "$USE_LOCALSTACK" = "yes" ]; then @@ -207,13 +225,17 @@ fi if [ -n "$GDC_DNS_PRI_IP" ]; then echo "GDC PRI DNS IP $GDC_DNS_PRI_IP" +fi +if [ -n "$GDC_DNS_SEC_IP" ]; then echo "GDC SEC DNS IP $GDC_DNS_SEC_IP" fi if [ -n "$PULUMI_VERSION" ]; then alias pr="clear;pulumi refresh -fy" alias pu="clear;pulumi up -fy" - echo "pulumi version $(pulumi version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "pulumi version $(pulumi version)" + fi fi if [ -r /usr/local/pyenv ]; then @@ -222,13 +244,17 @@ if [ -r /usr/local/pyenv ]; then command -v pyenv > /dev/null || export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" #eval "$(pyenv virtualenv-init -)" - echo "python version $(python --version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "python version $(python --version)" + fi fi if [ -r ~/venv/bin/activate ]; then echo "activating python venv" . "$HOME/venv/bin/activate" - echo "python version $(python --version)" + if [ "$SHOW_VERSIONS_ON_LOGIN" = "yes" ]; then + echo "python version $(python --version)" + fi fi export PATH="$PATH:/root/bin-extra/ls" diff --git a/readme.md b/readme.md index 8c45f7e..49f8b58 100644 --- a/readme.md +++ b/readme.md @@ -136,6 +136,7 @@ These options control what packages / functionality are built into the container * USE_WORKSPACE=yes - mounts folder from host into /workspace folder in container. Setting this option to "no" is useful if you only want to use tools inside the container and not interact with a project. * USE_HOST_HOME=yes - mounts users home directory into container under /root/host-home. Required by some other options. * USE_HOME_BIN=no - copy bin folder from host home directory if it exists. Enables USE_HOST_HOME. +* SHOW_VERSIONS_ON_LOGIN=yes # show versions of installed tools on login * PULUMI_VERSION=latest - a version or "latest" must be specified for Pulumi to be installed. * TERRAFORM_VERSION=latest - default is latest. Versions are here. https://releases.hashicorp.com/terraform * PHP_VERSION= - installs any of the following PHP versions 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2.