115 lines
3.9 KiB
Bash
Executable File
115 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Shell Repos Environment
|
|
# Customize Bash Shell setup here
|
|
# if bash is not installed then don't bother to continue
|
|
! command -v bash >/dev/null 2>&1 && echo no bash command && return 1
|
|
export SHELL=$(command -v bash )
|
|
|
|
# sourced for non-login interactive shells
|
|
# sourced via /etc/bash.bashrc so for all machine users
|
|
# $BASH_SHELL_BASE # this MUST be set in /etc/profile
|
|
# $BASH_SHELL_HOST=$BASH_SHELL_BASE
|
|
# $BASH_SHELL_NETWORK/all
|
|
# $BASH_NETWORK_DIR # extra directory to look for networks, $BASH_SHELL_NETWORK is always checked
|
|
# $BASH_SHELL_HOST/all
|
|
# $BASH_SHELL_HOST/<hostname>
|
|
# also
|
|
# sourced via $HOME/.bashrc
|
|
# $HOME/shell or $HOME/BASH_SHELL_USER
|
|
|
|
# for the rare interactive login shell
|
|
# if you don't want the repos above sourced uncomment this next line
|
|
# $NO_LOGIN_BASHRC=true
|
|
# this does not effect non-interactive login shells like at user first login
|
|
|
|
# within each of those directories if load.sh exits it will be run
|
|
# otherwise files will be sourced exactly like load.sh in the base
|
|
|
|
# Using base shell setup repository
|
|
# https://git.kebler.net/kebler.net/bash-shell-base.git
|
|
|
|
|
|
# BASH_SHELL_BASE is set in /etc/profile do not change here!
|
|
|
|
export BASH_SHELL_LOAD=$BASH_SHELL_BASE/load.sh # load.sh is default
|
|
export BASH_SHELL_STARTUP=$BASH_SHELL_BASE/startup.sh # strtup.sh is default
|
|
# if uncommented next lines sets up implicit sourcing for non-interactive shells
|
|
|
|
# echo ----NON_INTERACTIVE SHELL-----
|
|
# echo enabling bash shell repos for non-inactive shell
|
|
# export BASH_ENV=$BASH_SHELL_LOAD # same as interactive shell, beware usually too much
|
|
export BASH_ENV=$BASH_SHELL_BASE/module.lib # load module loading functions
|
|
# echo enabling aliases with non-interactive shell
|
|
export BASH_USE_ALIAS=true # will source aliases for non-interactive
|
|
# echo see $BASH_SHELL_BASE/shell.env
|
|
# echo ---------
|
|
|
|
# if not using implicit sourcing for non-interactive shells then one can do this per script
|
|
##################
|
|
# expanding aliases is optional
|
|
# shopt -s expand_aliases
|
|
# source $BASH_SHELL_LOAD
|
|
# < your script code >
|
|
# shopt -u expand_aliases
|
|
####################
|
|
|
|
# set ssh session if non-interactive only
|
|
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
|
|
|
|
|
|
BASH_SHELL_DIRS="$BASH_SHELL_BASE "
|
|
declare parent
|
|
parent=$(dirname $BASH_SHELL_BASE)
|
|
|
|
# Any Host
|
|
BASH_SHELL_ANY_HOST=${parent}/any/host # or set to
|
|
# export BASH_SHELL_ALL_HOSTS=<some directory>
|
|
# Host
|
|
BASH_SHELL_HOST=$parent/$(hostname)
|
|
# export BASH_SHELL_HOST=<some directory>
|
|
|
|
BASH_SHELL_ANY_NETWORK=$parent/any/network
|
|
# export BASH_SHELL_ALL_NETWORKS=<some directory>
|
|
|
|
# by default USER shell sources will be looked for under $HOME/shell
|
|
# but the default directory for all users can be set manually below
|
|
# export BASH_SHELL_USER=<some directory under $HOME>
|
|
# add this export to .bashrc for custom directory. This can be done during or after using the user setup script
|
|
|
|
[[ -d $BASH_SHELL_ANY_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_HOST " && export BASH_SHELL_ANY_HOST
|
|
[[ -d $BASH_SHELL_ANY_NETWORK ]] && BASH_SHELL_DIRS+="$BASH_SHELL_ANY_NETWORK " && export BASH_SHELL_ANY_NETWORK
|
|
|
|
# now load and export module loading functions library
|
|
source $BASH_SHELL_BASE/module.lib
|
|
|
|
module_load network-dirs
|
|
|
|
BASH_NETWORKS_DIR=$parent/networks
|
|
# BASH_NETWORKS_DIR=<some directory> # alt directory to look for networks
|
|
export BASH_NETWORKS_DIR
|
|
|
|
# These will be loaded for all users on a host
|
|
network_dirs "$BASH_SHELL_HOST/.networks"
|
|
|
|
[[ -d $BASH_SHELL_HOST ]] && BASH_SHELL_DIRS+="$BASH_SHELL_HOST " && export BASH_SHELL_HOST
|
|
|
|
# these loaded only for specific user on a host
|
|
network_dirs "$HOME/${BASH_SHELL_USER:-"shell"}/.networks"
|
|
|
|
export BASH_SHELL_DIRS
|
|
|
|
# echo ALL DIRS: $BASH_SHELL_DIRS
|
|
|
|
# cat $HOME/.bashrc
|
|
# source "$HOME/.bashrc"
|
|
|
|
# env | grep BASH
|
|
# env | grep NETWORK_DIRS
|
|
# echo ---------------------------------
|
|
# echo $BASH_SHELL_DIRS
|
|
# echo ---------------------------------
|
|
|
|
|
|
|
|
# echo end shell env
|