40 lines
926 B
Bash
40 lines
926 B
Bash
|
#!/bin/bash
|
||
|
function startup_load () {
|
||
|
|
||
|
local SDIRS
|
||
|
local SDIR
|
||
|
local DIRS
|
||
|
DIRS=( \
|
||
|
$BASH_SHELL_BASE \
|
||
|
$BASH_SHELL_NETWORK/all \
|
||
|
$BASH_SHELL_NETWORK/$NETWORKNAME \
|
||
|
$BASH_SHELL_HOST/all \
|
||
|
$BASH_SHELL_HOST/$(hostname) \
|
||
|
)
|
||
|
echo directories ${DIRS[*]}
|
||
|
[[ $1 ]] && DIRS=("$1")
|
||
|
llog "startup directories to try ${DIRS[*]}"
|
||
|
SDIRS=()
|
||
|
j=0
|
||
|
cnt=${#DIRS[@]}
|
||
|
for ((i=0;i<cnt;i++)); do
|
||
|
DIR="${DIRS[i]}/startup"
|
||
|
[ -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[@]}")
|
||
|
|
||
|
# echo -e "Statup Directories to source \n ${SDIRS[@]} \n"
|
||
|
source $BASH_SHELL_BASE/source-dir.func
|
||
|
|
||
|
for SDIR in "${SDIRS[@]}"
|
||
|
do
|
||
|
llog "startup dir to source $SDIR"
|
||
|
source_dir -p "archive" -x '"*.off" "*.md"' -d 0 $SDIR
|
||
|
done
|
||
|
}
|
||
|
|
||
|
# if script was executed then call the function
|
||
|
(return 0 2>/dev/null) || startup_load
|