additional network shell directories now set by a .network file under the $HOSTNAME host shell directory (for all users) or the same within the USER shell directory for per user networks. Network proceeded by ! indicates the home/lan network of that machine.
Also added -t to _find for setting the search type.master
parent
2ec857b1c2
commit
75297c7cdb
28
load.sh
28
load.sh
|
@ -100,6 +100,34 @@ function shell_process_directory () {
|
||||||
unset BASH_SHELL_BASE_LOADED
|
unset BASH_SHELL_BASE_LOADED
|
||||||
unset BASH_SHELL_LOADED
|
unset BASH_SHELL_LOADED
|
||||||
|
|
||||||
|
# add in any network directories
|
||||||
|
declare networks
|
||||||
|
source "$HOME/.bashrc"
|
||||||
|
networks="$HOME/${BASH_SHELL_USER:-"bash/shell"}/.networks"
|
||||||
|
NETWORK_DOMAINS="$([[ -f $networks ]] && cat $networks) "
|
||||||
|
# These will be loaded for all users
|
||||||
|
networks="$BASH_SHELL_HOST/$(hostname)/.networks"
|
||||||
|
NETWORK_DOMAINS+="$([[ -f $networks ]] && cat $networks)"
|
||||||
|
NETWORK_DOMAINS=(${NETWORK_DOMAINS})
|
||||||
|
|
||||||
|
if [[ ! $NETWORK_DOMAINS = "" ]]; then
|
||||||
|
declare domain
|
||||||
|
BASH_SHELL_NETWORK_DIRS=""
|
||||||
|
for domain in "${NETWORK_DOMAINS[@]}"; do
|
||||||
|
# echo processing ${BASH_SHELL_NETWORK}/${domain}
|
||||||
|
if [[ ${domain} = !* ]]; then
|
||||||
|
domain=${domain/#!/}
|
||||||
|
export NETWORK_HOME=$domain
|
||||||
|
fi
|
||||||
|
if [[ -d ${BASH_SHELL_NETWORK}/${domain} ]]; then
|
||||||
|
BASH_SHELL_NETWORK_DIRS+="${BASH_SHELL_NETWORK}/${domain} "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset domain
|
||||||
|
export BASH_SHELL_NETWORK_DIRS
|
||||||
|
BASH_SHELL_DIRS+=" ${BASH_SHELL_NETWORK_DIRS}"
|
||||||
|
fi
|
||||||
|
|
||||||
# echo bash shell dirs: $BASH_SHELL_DIRS
|
# echo bash shell dirs: $BASH_SHELL_DIRS
|
||||||
dirs=${1:-$BASH_SHELL_DIRS}
|
dirs=${1:-$BASH_SHELL_DIRS}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,12 @@ local HIDDEN
|
||||||
declare OPTION
|
declare OPTION
|
||||||
declare OPTARG
|
declare OPTARG
|
||||||
declare OPTIND
|
declare OPTIND
|
||||||
while getopts 'p:d:e:n:f:h' OPTION; do
|
while getopts 't:p:d:e:n:f:h' OPTION; do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
|
t)
|
||||||
|
TYPE=$OPTARG
|
||||||
|
# echo "TYPE $TYPE"
|
||||||
|
;;
|
||||||
f)
|
f)
|
||||||
EXCLUDE_FILE=$OPTARG
|
EXCLUDE_FILE=$OPTARG
|
||||||
# echo EXCLUDE FILE $EXCLUDE_FILE >&2
|
# echo EXCLUDE FILE $EXCLUDE_FILE >&2
|
||||||
|
@ -110,7 +114,9 @@ fi
|
||||||
local FIND
|
local FIND
|
||||||
FIND="command find $DIR"
|
FIND="command find $DIR"
|
||||||
FIND+=$([ ! $DEPTH == 0 ] && echo " -maxdepth $DEPTH ")
|
FIND+=$([ ! $DEPTH == 0 ] && echo " -maxdepth $DEPTH ")
|
||||||
FIND+=" -type f "
|
# FIND+=" -type $([ $TYPE ] && echo "$TYPE" || echo "f")"
|
||||||
|
TYPE=${TYPE:-f}
|
||||||
|
FIND+=" -type $TYPE "
|
||||||
# include HIDDEN files and directories IS FALSE BY DEFULT
|
# include HIDDEN files and directories IS FALSE BY DEFULT
|
||||||
[[ ! $HIDDEN ]] && FIND+="! -path \"*/.*/*\" ! -name \".*\" "
|
[[ ! $HIDDEN ]] && FIND+="! -path \"*/.*/*\" ! -name \".*\" "
|
||||||
|
|
||||||
|
|
36
shell.env
36
shell.env
|
@ -52,43 +52,29 @@ export BASH_USE_ALIAS=true # will source aliases for non-interactive
|
||||||
# set ssh session if non-interactive only
|
# set ssh session if non-interactive only
|
||||||
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
|
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
|
||||||
|
|
||||||
# identify a network name that this host resides on
|
|
||||||
# make a directory of the same name
|
|
||||||
# if unset then only /all will be sourced
|
|
||||||
# TODO just read all directories in BASH_SHELL_NETWORK.
|
|
||||||
export NETWORK_DOMAINS=(238.kebler.net 645.kebler.net 3115.kebler.net 312.kebler.net)
|
|
||||||
# network domain folder entry will be made for each domain set, first is home domain, others via vpn
|
|
||||||
if [[ $NETWORK_DOMAINS ]]; then
|
|
||||||
export NETWORK_HOME=${NETWORK_DOMAINS[0]}
|
|
||||||
# TODO needs to be automatically set not hard coded
|
|
||||||
declare parent
|
declare parent
|
||||||
parent=$(dirname $BASH_SHELL_BASE)
|
parent=$(dirname $BASH_SHELL_BASE)
|
||||||
|
|
||||||
export BASH_SHELL_NETWORK=$([[ -d $parent/network ]] && echo $parent/network || echo /opt/bash/shell/network)
|
|
||||||
# or comment above and set explictly
|
|
||||||
# export BASH_SHELL_NETWORK=<some directory>
|
|
||||||
|
|
||||||
declare domain
|
|
||||||
BASH_SHELL_NETWORK_DIRS=""
|
|
||||||
for domain in "${NETWORK_DOMAINS[@]}"; do
|
|
||||||
BASH_SHELL_NETWORK_DIRS+="${BASH_SHELL_NETWORK}/${domain} "
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
unset domain
|
|
||||||
export BASH_SHELL_NETWORK_DIRS
|
|
||||||
|
|
||||||
export BASH_SHELL_HOST=$([[ -d $parent/host ]] && echo $parent/host || echo /opt/bash/shell/host)
|
export BASH_SHELL_HOST=$([[ -d $parent/host ]] && echo $parent/host || echo /opt/bash/shell/host)
|
||||||
# or comment above and set explictly
|
# or comment above and set explictly
|
||||||
# export BASH_SHELL_HOST=<some directory>
|
# export BASH_SHELL_HOST=<some directory>
|
||||||
|
|
||||||
# by default SHELL sources will be looked for under $HOME/bash/shell
|
# identify a network name that this host resides on
|
||||||
# but can be user set below to $HOME/$BASH_SHELL_USER
|
# make a directory of the same name
|
||||||
|
|
||||||
|
export BASH_SHELL_NETWORK=$([[ -d $parent/network ]] && echo $parent/network || echo /opt/bash/shell/network)
|
||||||
|
# or comment above and set explictly
|
||||||
|
# export BASH_SHELL_NETWORK=<some directory>
|
||||||
|
|
||||||
|
# by default USER shell sources will be looked for under $HOME/bash/shell
|
||||||
|
# but the default directory for all users can be set manually below
|
||||||
# export BASH_SHELL_USER=<some directory under $HOME>
|
# 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
|
||||||
|
|
||||||
temp="
|
temp="
|
||||||
$BASH_SHELL_BASE
|
$BASH_SHELL_BASE
|
||||||
$BASH_SHELL_NETWORK/all
|
$BASH_SHELL_NETWORK/all
|
||||||
${BASH_SHELL_NETWORK_DIRS[@]}
|
|
||||||
$BASH_SHELL_HOST/all
|
$BASH_SHELL_HOST/all
|
||||||
$BASH_SHELL_HOST/$(hostname)
|
$BASH_SHELL_HOST/$(hostname)
|
||||||
"
|
"
|
||||||
|
|
Reference in New Issue