#!/bin/bash # module_load network-dirs # # These will be loaded for all users on a host # network_dirs "$BASH_SHELL_HOST/.networks" # # these loaded only for specific user on a host and take precedence # network_dirs "$HOME/${BASH_SHELL_USER:-"shell"}/.networks" # # these are exported from network_dirs # # env | grep NETWORK # # NETWORK_HOME # # NETWORK_HOME_DIR # # BASH_SHELL_NETWORK_DIRS loadssh () { module_load ssh module_load ssh-config ssh_config module_load ssh-copy module_load ssh-pubkey module_load sshfs enable_mounts # echo ssh modules are loaded } load_home_network() { # unset BASH_SHELL_NETWORKS_LOAD # export BASH_SHELL_HOME_NETWORK_LOAD=true _load_networks -h # loadssh } load_all_networks () { # unset BASH_SHELL_HOME_NETWORK_LOAD # export BASH_SHELL_NETWORKS_LOAD=true _load_networks -a # dssh } load_network () { unset BASH_SHELL_HOME_NETWORK_LOAD unset BASH_SHELL_NETWORKS_LOAD _load_networks $@ # loadssh } clear_networks () { unset BASH_SHELL_NETWORKS_LOAD unset BASH_SHELL_HOME_NETWORK_LOAD unset BASH_SHELL_NETWORK_DIRS unset BASH_SHELL_NETWORK reload_shell ssh_config } # called from reload_shell _load_networks () { # echo load_networks called $@ [[ $1 == "-h" ]] && BASH_SHELL_HOME_NETWORK_LOAD=true && shift 1 [[ $1 == "-a" ]] && BASH_SHELL_NETWORKS_LOAD=true && shift 1 if [[ ! $BASH_SHELL_NETWORKS_LOAD ]] && [[ ! $BASH_SHELL_HOME_NETWORK_LOAD ]]; then [[ ! $1 ]] && return 0 # echo $1 was passed fi # echo loading networks module_load network-dirs # echo before unset $BASH_SHELL_NETWORK_DIRS unset BASH_SHELL_NETWORK_DIRS unset BASH_NETWORK_HOME unset BASH_NETWORK_HOME_DIR # echo after unset $BASH_SHELL_NETWORK_DIRS if [[ $1 ]]; then network_dirs $1 else # These will be added for all users on a host network_dirs "$BASH_SHELL_HOST/.networks" # these added only for specific user on a host and take precedence network_dirs "$HOME/${BASH_SHELL_USER:-"shell"}/.networks" # these added only for development and take precedence network_dirs "$BASH_SHELL_DEV/.networks" fi if [[ $BASH_SHELL_HOME_NETWORK_LOAD ]]; then # echo Home nework $BASH_NETWORK_HOME_DIR processed shell_process_directory $BASH_NETWORK_HOME_DIR export BASH_SHELL_NETWORK_DIRS=$BASH_NETWORK_HOME_DIR else for dir in ${1:-$BASH_SHELL_NETWORK_DIRS}; do # echo network $dir processed shell_process_directory $dir done fi unset BASH_SHELL_NETWORKS_LOAD unset BASH_SHELL_HOME_NETWORK_LOAD loadssh [[ $BASH_SHELL_LOADED ]] && load_shell_host_user_dev # echo loaded $BASH_SHELL_NETWORK_DIRS }