diff --git a/README.md b/README.md index 7ab2992..728ca20 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,6 @@ Clone to a directory `git clone https://git.kebler.net/bashrc ` suggestion: /opt/shell/base -now edit your `~/.bashrc` with nano or other available editor - -add this -``` -# BASH_SHELL is a common parent directory that should be set in /etc/bash.bashrc -export BASH_SHELL_REPO=/setup. -source $BASH_SHELL_REPO/setup.sh -``` The idea is to keep the .bashrc file completely clean and manage this repo instead so you should really find a home for all the existing content of your .bashrc file within the repo @@ -31,13 +23,13 @@ if you include any of these environment variables all files in there directories # unless below specific directories are set # shell files are sourced in this order # sourced via /etc/bash.bashrc so for all machine users -# $BASH_SHELL_BASE # this MUST be set in /etc/bash.bashrc +# $BASH_SHELL_BASE # this is set in /etc/bash.bashrc and etc/profile via the deploy script # $BASH_SHELL_NETWORK/all # $BASH_SHELL_NETWORK/$NETWORKNAME # $BASH_SHELL_HOST/all # $BASH_SHELL_HOST/ # sourced via $HOME/.bashrc -# $HOME/shell or $HOME/BASH_SHELL_USER +# $HOME/.shell or $HOME/BASH_SHELL_USER # within each of those directories if setup.sh exits it will be run # otherwise files will be sourced exactly like in the base @@ -52,7 +44,7 @@ export BASH_SHELL_NETWORK=$BASH_SHELL/network # will use $BASH_SHELL_HOST/ unless specifically set export BASH_SHELL_HOST=$BASH_SHELL/host -# by default SHELL sources will be looked for under $HOME/bash/shell +# by default SHELL sources will be looked for under $HOME/.shell # but can be user set below to $HOME/$BASH_SHELL_USER # export BASH_SHELL_USER= if there is a script setup.sh in the root of these directoies it will be run. If not then all files no matter how deep will be sourced in alpha order order. @@ -63,10 +55,7 @@ If need to turn off a file just add `.off` to the file name rather than move or If you are really done with something but want to keep a copy in the repo move it to /archive folder within the primary subfolders -if sourcing some file depends on another preface with numbers to put it before. Functions are all sourced before aliases so can be refered to there. +if sourcing some file depends on another preface with numbers to put it before. Functions are all sourced before aliases so can be referred to there. Be aware that an alias or function set in the repo could be subsuming some existing binary or script. - -`[[ $BASHPID -eq $$ ]] && echo was called directly || echo was called in a subshell` -https://unix.stackexchange.com/a/594809/201387 diff --git a/function/logit b/function/logit index c643f35..da876c7 100644 --- a/function/logit +++ b/function/logit @@ -19,7 +19,7 @@ function logit(){ } # -# LOG_DIR=/opt/bash/logs +# LOG_DIR=/shell/logs # mkdir -p $LOG_DIR # LOG_FILE=$LOG_DIR/bash_profile # diff --git a/load.sh b/load.sh index 8937dbd..f53bd8e 100755 --- a/load.sh +++ b/load.sh @@ -103,7 +103,7 @@ unset BASH_SHELL_LOADED # add in any network directories declare networks source "$HOME/.bashrc" -networks="$HOME/${BASH_SHELL_USER:-"bash/shell"}/.networks" +networks="$HOME/${BASH_SHELL_USER:-".shell"}/.networks" NETWORK_DOMAINS="$([[ -f $networks ]] && cat $networks) " # These will be loaded for all users networks="$BASH_SHELL_HOST/$(hostname)/.networks" diff --git a/module.lib b/module.lib index ad9dfec..b5878f0 100644 --- a/module.lib +++ b/module.lib @@ -36,7 +36,7 @@ local DIRS local MODULE=$1 # Precidence is user. current hosts, all hosts, current network, all networks, base DIRS=( \ -$([ $BASH_SHELL_USER ] && echo $HOME/$BASH_SHELL_USER || echo $HOME/bash/shell) \ +$([ $BASH_SHELL_USER ] && echo $HOME/$BASH_SHELL_USER || echo $HOME/.shell) \ $BASH_SHELL_HOST/$(hostname) $BASH_SHELL_HOST/all \ $BASH_SHELL_NETWORK/$NETWORKNAME \ diff --git a/setup/deploy-user.sh b/setup/deploy-user.sh index 7e86897..0b3a013 100755 --- a/setup/deploy-user.sh +++ b/setup/deploy-user.sh @@ -34,9 +34,9 @@ for file in $files; do cmd="install -C -m 660 -o $_USER -g sudo $file $_USER_DIR" [[ $USER = "$_USER" ]] && eval $cmd || sudo -E -- bash -c "$cmd" done -echo "the default user bash shell repo subdirecty is \`bash/shell\`" +echo "the default user bash shell repo subdirecty is \`.shell\`" echo "enter an alternative subdirectory under $_USER_DIR or just to accept default" read -e answer -[[ ! $answer ]] && echo will source default user shell repo at $_USER_DIR/bash/shell && exit 0 +[[ ! $answer ]] && echo will source default user shell repo at $_USER_DIR/.shell && exit 0 sed -i '/[[ $BASH_SHELL_BASE_LOADED = true ]]/ i\ BASH_SHELL_USER='$answer'' $_USER_DIR/.bashrc echo will be processing user shell repo at $_USER_DIR/$answer diff --git a/setup/deploy.sh b/setup/deploy.sh index e6069bd..0ae7e24 100755 --- a/setup/deploy.sh +++ b/setup/deploy.sh @@ -35,7 +35,8 @@ read -e answer echo -----------------;echo deploying /etc shell files files=$(find $BASH_SHELL_BASE/setup/etc/ -maxdepth 1 -type f) for file in $files; do sudo install -C -m 644 -o root -g root $file /etc; done -echo setting BASH_SHELL_BASE to $BASH_SHELL_BASE in etc/profile +echo setting BASH_SHELL_BASE to $BASH_SHELL_BASE in etc/bash.bashrc and /etc/profile +sudo sed -i 's:_BASH_SHELL_BASE_:'${BASH_SHELL_BASE}':' /etc/bash.bashrc sudo sed -i 's:BASH_SHELL_BASE=.*:BASH_SHELL_BASE='${BASH_SHELL_BASE}':' /etc/profile files=$(find $BASH_SHELL_BASE/setup/etc/profile.d -maxdepth 1 -type f) for file in $files; do sudo install -C -m 644 -o root -g root $file /etc/profile.d; done diff --git a/setup/etc/bash.bashrc b/setup/etc/bash.bashrc index bcf7522..feb99d3 100644 --- a/setup/etc/bash.bashrc +++ b/setup/etc/bash.bashrc @@ -7,7 +7,7 @@ shopt -q login_shell && export SHELL_LOGIN=true [ $EUID -eq 0 ] && export USER_ROOT=true #uncomment these for debugging. -# echo ---- sourcing system wide bash.bashrc --- +# echo ---- sourcing system wide bash.bashrc --- # [[ $USER_ROOT ]] && echo 'Root User' || echo 'Non Root User' # [[ $SHELL_INTERACTIVE ]] && echo 'Interactive' || echo 'Not interactive' # [[ $SHELL_LOGIN ]] && echo 'Login shell' || echo 'Not login shell' @@ -19,8 +19,7 @@ source /etc/profile else # Set the initial path export PATH=/bin:/usr/bin:/usr/local/bin -# set this for access to any shell sources -export BASH_SHELL_BASE=/opt/bash/shell/base -# loading module functions -source $BASH_SHELL_BASE/module.lib +# loading just the module functions which will give access to load any module in shell dirs +# _BASH_SHELL_BASE_ is/was replaced by the deploy script with actual path +source _BASH_SHELL_BASE_/module.lib fi \ No newline at end of file diff --git a/setup/user/.bashrc b/setup/user/.bashrc index 9ac9cbc..431624d 100644 --- a/setup/user/.bashrc +++ b/setup/user/.bashrc @@ -11,7 +11,7 @@ if ( [[ $SHELL_INTERACTIVE ]] );then if ( [[ $BASH_SHELL_BASE_LOADED = true ]] ) ; then # echo loading user shell sources - export BASH_SHELL_USER=${BASH_SHELL_USER:-"bash/shell"} + export BASH_SHELL_USER=${BASH_SHELL_USER:-".shell"} [[ -d $HOME/$BASH_SHELL_USER ]] && shell_process_directory "$HOME/$BASH_SHELL_USER" ||\ echo no user shell directory $HOME/$BASH_SHELL_USER to process, create one or clone a template fi diff --git a/shell.env b/shell.env index bb6647f..936bfb5 100755 --- a/shell.env +++ b/shell.env @@ -67,7 +67,7 @@ export BASH_SHELL_NETWORK=$([[ -d $parent/network ]] && echo $parent/network || # or comment above and set explictly # export BASH_SHELL_NETWORK= -# by default USER shell sources will be looked for under $HOME/bash/shell +# 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= # add this export to .bashrc for custom directory. This can be done during or after using the user setup script