shell-base/startup.sh

29 lines
875 B
Bash
Executable File

#!/bin/bash
[[ $(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
DIRS=(${BASH_SHELL_DIRS})
# llog "startup directories to try ${DIRS[*]}"
SDIRS=()
j=0
cnt=${#DIRS[@]}
for ((i=0;i<cnt;i++)); do
# echo $i of $cnt
DIR="${DIRS[i]}/startup"
# echo ----- trying $DIR
[ -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[@]}"
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