refactor for shell.env files are loaded early at user login

master
David Kebler 2024-11-02 11:30:32 -07:00
parent ea8c78f72c
commit 56be5950c8
2 changed files with 16 additions and 12 deletions

11
load.sh
View File

@ -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

View File

@ -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=<some directory>
[[ -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=<some directory>
[[ -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=<some directory>
# 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