function enable network mounts added (in a mnt file) under /ssh

master
Kebler Network System Administrator 2022-12-23 08:30:48 -08:00
parent 279d5c1863
commit d9fa3b6c74
1 changed files with 33 additions and 0 deletions

View File

@ -120,3 +120,36 @@ function mntBackup() {
function umntBackup() {
usmount /backup/remote
}
function enable_mounts() {
DIRS=($BASH_SHELL_NETWORK_DIRS "$BASH_SHELL_HOST" "$HOME/$BASH_SHELL_USER" "$BASH_SHELL_DEV")
# echo DIRS "${DIRS[@]}"
CDIRS=()
j=0
cnt=${#DIRS[@]}
for ((i = 0; i < cnt; i++)); do
# echo $i of $cnt
# looks in ssh/config subdirectory of each DIRS if not passed
DIR="${DIRS[i]}/ssh/mounts"
# echo ----- $i, ${DIRS[i]} trying $DIR
[ -d $DIR ] && CDIRS[j]=$DIR
j+=1 || echo no directory $DIR
done
# CDIRS=("${CDIRS[@]}")
# echo ${CDIRS[@]}
module_load file
for CDIR in "${CDIRS[@]}"; do
# echo $CDIR
for f in $(_find -n '*.mnt' -p 'archive off' -d 0 $CDIR); do
# echo "Processing $f";
[[ $f ]] && source "$f"
done
done
[[ -f "$HOME/.ssh/mounts" ]] && source "$HOME/.ssh/mounts"
}