From 56be5950c847e527bbb16c0cfeeee8d46edf0bc0 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Sat, 2 Nov 2024 11:30:32 -0700 Subject: [PATCH] refactor for shell.env files are loaded early at user login --- load.sh | 11 ++++++----- shell.env | 17 ++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/load.sh b/load.sh index 9106d1e..dbc6a59 100755 --- a/load.sh +++ b/load.sh @@ -27,11 +27,12 @@ reload_user() { cd $save } -load_custom_shell_env () { - [[ -f $BASH_SHELL_HOSTNAME/shell.env ]] && source $BASH_SHELL_HOSTNAME/shell.env - [[ -f $BASH_SHELL_USER_DIR/shell.env ]] && source $BASH_SHELL_USER_DIR/shell.env - [[ -f $BASH_SHELL_DEV/shell.env ]] && shell_process_directory $BASH_SHELL_DEV/shell.env -} +# remove, loading in shell.env +# load_custom_shell_env () { +# [[ -f $BASH_SHELL_HOSTNAME/shell.env ]] && source $BASH_SHELL_HOSTNAME/shell.env +# [[ -f $BASH_SHELL_USER_DIR/shell.env ]] && source $BASH_SHELL_USER_DIR/shell.env +# [[ -f $BASH_SHELL_DEV/shell.env ]] && shell_process_directory $BASH_SHELL_DEV/shell.env +# } load_shell_host () { module_load shell-process-directory diff --git a/shell.env b/shell.env index f2618e6..7760787 100755 --- a/shell.env +++ b/shell.env @@ -79,28 +79,30 @@ BASH_SHELL_DIRS="$BASH_SHELL_BASE " declare parent parent="$(dirname $BASH_SHELL_BASE)" -# Any Host +# Mainly used for installing scripts to the hostname directory (see below) BASH_SHELL_HOST="${parent}/host" -# export BASH_SHELL_ALL_HOSTS= [[ -d $BASH_SHELL_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_HOST " && export BASH_SHELL_HOST +# source any additional shell env +[[ -f $BASH_SHELL_HOST/shell.env ]] && source $BASH_SHELL_HOST/shell.env BASH_SHELL_NETWORK=${parent}/network -# BASH_SHELL_ALL_NETWORKS= [[ -d $BASH_SHELL_NETWORK ]] && BASH_SHELL_DIRS+="$BASH_SHELL_NETWORK " && export BASH_SHELL_NETWORK +# source any additional shell env +[[ -f $BASH_SHELL_NETWORK/shell.env ]] && source $BASH_SHELL_NETWORK/shell.env + # these are all the base directories to source export BASH_SHELL_DIRS -# machine specific shell +# machine specific shell based on hostname BASH_SHELL_HOSTNAME="$parent/$([[ -f /etc/hostname ]] && cat /etc/hostname || echo nohostname)" -# BASH_SHELL_HOSTNAME= -# if there is a host directory add it to list and export env var -# [[ -d $BASH_SHELL_HOSTNAME ]] && BASH_SHELL_DIRS+="$BASH_SHELL_HOSTNAME " && export BASH_SHELL_HOSTNAME [[ -d $BASH_SHELL_HOSTNAME ]] && export BASH_SHELL_HOSTNAME +[[ -f $BASH_SHELL_HOSTNAME/shell.env ]] && source $BASH_SHELL_HOSTNAME/shell.env # if this directory exists it is included first in the sourcing # if allows on the develop scripts and modules, etc for later incorporation into a repo BASH_SHELL_DEV=${BASH_SHELL_DEV:-/opt/shell} [[ -d $BASH_SHELL_DEV ]] && export BASH_SHELL_DEV +[[ -f $BASH_SHELL_DEV/shell.env ]] && source $BASH_SHELL_DEV/shell.env # #################### NETWORKING ######################### @@ -119,6 +121,7 @@ export BASH_NETWORKS_DIR [[ -f $HOME/.ucishell ]] && source $HOME/.ucishell > /dev/null # by default USER shell sources will be looked for under $HOME/shell export BASH_SHELL_USER_DIR=${BASH_SHELL_USER_DIR:-$HOME/shell} +[[ -f $BASH_SHELL_USER_DIR/shell.env ]] && source $BASH_SHELL_USER_DEV/shell.env # now load and export bootstrap module loading functions library so it is always available even for non-interactive shells set -a;source $BASH_SHELL_BASE/module.base;set +a