2020-11-10 14:09:08 -08:00
|
|
|
#!/bin/bash
|
|
|
|
function startup_load () {
|
|
|
|
local SDIRS
|
|
|
|
local SDIR
|
|
|
|
local DIRS
|
2020-11-20 08:48:48 -08:00
|
|
|
local DIR
|
|
|
|
local excludes
|
|
|
|
|
|
|
|
|
|
|
|
[[ $(declare -F | grep module_load) ]] && echo module lib already loaded || source "$BASH_SHELL_BASE/module.lib"
|
|
|
|
module_load file
|
|
|
|
[[ $? -ne 0 ]] && echo unable to access the file module, aboarting load && return 1
|
|
|
|
|
|
|
|
|
|
|
|
[[ $1 ]] && DIRS=($1) || DIRS=(${BASH_SHELL_DIRS})
|
|
|
|
# llog "startup directories to try ${DIRS[*]}"
|
2020-11-10 14:09:08 -08:00
|
|
|
SDIRS=()
|
|
|
|
j=0
|
|
|
|
cnt=${#DIRS[@]}
|
|
|
|
for ((i=0;i<cnt;i++)); do
|
2020-11-20 08:48:48 -08:00
|
|
|
# echo $i of $cnt
|
2020-11-10 14:09:08 -08:00
|
|
|
DIR="${DIRS[i]}/startup"
|
2020-11-20 08:48:48 -08:00
|
|
|
# echo ----- trying $DIR
|
2020-11-10 14:09:08 -08:00
|
|
|
[ -d $DIR ] && SDIRS[j]=$DIR && j+=1
|
|
|
|
done
|
|
|
|
|
|
|
|
# STARTUP_DIRS is array of any other startup directores where scripts may be loaded from
|
|
|
|
[ $STARTUP_DIRS ] && SDIRS=("$STARTUP_DIRS" "${SDIRS[@]}")
|
|
|
|
|
|
|
|
for SDIR in "${SDIRS[@]}"
|
2020-11-20 08:48:48 -08:00
|
|
|
do
|
|
|
|
DIR=$(dirname $SDIR)
|
|
|
|
IGNORE_FILE="$([[ -f "$DIR/.bash-shell-ignore" ]] && echo "$DIR" || echo "$BASH_SHELL_BASE")/.bash-shell-ignore"
|
|
|
|
llog "startup dir to source $SDIR"
|
|
|
|
source_dir -f "$IGNORE_FILE" -d 0 $SDIR
|
|
|
|
done
|
2020-11-10 14:09:08 -08:00
|
|
|
}
|
2020-11-13 10:25:04 -08:00
|
|
|
|
|
|
|
# if script was executed then call the function
|
|
|
|
(return 0 2>/dev/null) || startup_load
|