This is part of the Zsh Utilities.
This file sets different environment variables given the hostname of the
machine. Using org-mode’s folding, each item contains the configuration for a
given hostname. The function name must be __configure_$(hostname)
in such a
way it should be easy to add its own configuration.
function __configure_default ()
{
pkgtools::at_function_enter __configure_default
if $(pkgtools::in_docker); then
pkgtools::msg_notice "Configure docker container"
local intel_libs=/opt/intel
if [ -d ${intel_libs} ]; then
pkgtools::reset_variable MKLROOT ${intel_libs}/mkl
pkgtools::reset_variable MKLLIB ${MKLROOT}/lib/intel64
pkgtools::add_path_to_LD_LIBRARY_PATH ${MKLLIB}
pkgtools::reset_variable IOMP5LIB ${intel_libs}/lib/intel64
pkgtools::add_path_to_LD_LIBRARY_PATH ${IOMP5LIB}
fi
fi
pkgtools::at_function_exit
return 0
}
function __configure_laptop ()
{
pkgtools::at_function_enter __configure_laptop
# Use 256 colors terminal
pkgtools::reset_variable TERM xterm-256color
# Homemade latex style
pkgtools::reset_variable TEXMFHOME ${HOME}/.config/texmf
pkgtools::reset_variable TEXMFOUTPUT /tmp
# Load Go Programming Language
pkgtools::reset_variable GOPATH ${HOME}/Development/go
pkgtools::add_path_to_PATH ${GOPATH}/bin
# Adding utilities path
pkgtools::add_path_to_PATH ${HOME}/.bin
# Reset LD_LIBRARY_PATH
unset LD_LIBRARY_PATH
# Set HOST
pkgtools::reset_variable HOST ${HOSTNAME}
pkgtools::reset_variable WORKDIR ${HOME}/Workdir
# SuperNEMO variable
pkgtools::reset_variable SNAILWARE_SIMULATION_DIR $WORKDIR/NEMO/supernemo/simulations
# Set EDITOR
pkgtools::reset_variable EDITOR "ec"
# Set __pycache__ directory
pkgtools::reset_variable PYTHONPYCACHEPREFIX $HOME/.cache/cpython/
pkgtools::at_function_exit
return 0
}
function __configure_lal_machines ()
{
pkgtools::at_function_enter __configure_lal_machines
umask 022
pkgtools::reset_variable EXPDIR /exp/nemo/garrido
pkgtools::reset_variable WORKDIR /exp/nemo/garrido/workdir
# Add homemade software
pkgtools::add_path_to_PATH ${EXPDIR}/software/bin
pkgtools::at_function_exit
return 0
}
function __configure_lyon_machines ()
{
pkgtools::at_function_enter __configure_lyon_machines
# # Redefine new group function
# if (( ! $+functions[newgroup] )); then
# function newgroup() {
# . /usr/local/shared/bin/newgroup.sh $@
# }
# fi
# PS3="Choose a setup: "
# setups=("supernemo" "cmb")
# select setup in "${setups[@]}"
# do
# case $setup in
# "supernemo")
# do_nemo_setup
# break
# ;;
# "cmb")
# do_cmb_setup
# break
# ;;
# esac
# done
# Homemade software for everybody
pkgtools::add_path_to_PATH ${SCRATCH_DIR}/software/bin
pkgtools::at_function_exit
return 0
}
function __configure_nersc_machines ()
{
pkgtools::at_function_enter __configure_nersc_machines
# function fix_permissions()
# {
# if [ -z $1 ]; then
# echo "ERROR: Missing directory"
# return 1
# fi
# # chmod 755 $(find $1 -type d)
# # chmod 644 $(find $PWD -type f)
# find $1 -type d -print0 | xargs -0 chmod 755
# find $1 -type f -print0 | xargs -0 chmod 644
# }
function module()
{
if [ -z "${LMOD_SH_DBG_ON+x}" ]; then
case "$-" in
*v*x*)
__lmod_sh_dbg='vx'
;;
*v*)
__lmod_sh_dbg='v'
;;
*x*)
__lmod_sh_dbg='x'
;;
esac;
fi;
if [ -n "${__lmod_sh_dbg:-}" ]; then
set +$__lmod_sh_dbg;
echo "Shell debugging temporarily silenced: export LMOD_SH_DBG_ON=1 for Lmod's output" 1>&2;
fi;
eval "$($LMOD_CMD shell "$@")" && eval "$(${LMOD_SETTARG_CMD:-:} -s sh)";
__lmod_my_status=$?;
if [ -n "${__lmod_sh_dbg:-}" ]; then
echo "Shell debugging restarted" 1>&2;
set -$__lmod_sh_dbg;
fi;
unset __lmod_sh_dbg;
return $__lmod_my_status
}
function ml()
{
eval "$($LMOD_DIR/ml_cmd "$@")"
}
pkgtools::at_function_exit
return 0
}
function __configure_machine ()
{
pkgtools::at_function_enter __configure_machine
# This must be done by default
export HOSTNAME=$(hostname)
if pkgtools::check_variable NERSC_HOST; then
export HOSTNAME=perlmutter
fi
case "$HOSTNAME" in
garrido-laptop|pc-91089|nb-garrido|garrido-xps)
__configure_laptop
;;
lx3.lal.in2p3.fr|nemo*.lal.in2p3.fr)
__configure_lal_machines
;;
ccige*|ccage*|cc*)
__configure_lyon_machines
;;
cori*|perlmutter*)
__configure_nersc_machines
;;
ruche*)
function module ()
{
eval $($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)
}
;;
*)
type __configure_$(hostname) | grep -q "shell function" > /dev/null 2>&1
if [ $? -eq 0 ]; then
__configure_$(hostname)
else
pkgtools::msg_debug "No configuration for machine '$(hostname)' has been found ! Use default one"
__configure_default
fi
;;
esac
pkgtools::at_function_exit
return 0
}