forked from WenbinHou/sysenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.bashrc
36 lines (26 loc) · 847 Bytes
/
env.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if [ "${BASH_SOURCE[0]}" == "$0" ]; then
echo "[ERROR] sysenv: $(realpath "$0") must be sourced but not invoked"
exit 1
fi
if [ -z "$SYSENV_OUTPUT_DIRECTORY" ]; then
export SYSENV_OUTPUT_DIRECTORY="/dev/shm/sysenv/${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
env-reload() {
if [ ! -r "$HOME/env.conf" ]; then
echo "[ERROR] sysenv: \$HOME/env.conf is not found"
return 1
fi
if [ ! -d "$SYSENV_OUTPUT_DIRECTORY" ]; then
mkdir -p "$SYSENV_OUTPUT_DIRECTORY"
fi
python "$(dirname "${BASH_SOURCE[0]}")/core.py" reload "$HOME/env.conf" "$SYSENV_OUTPUT_DIRECTORY/bashrc"
if [ $? == 0 ]; then
#cat "$SYSENV_OUTPUT_DIRECTORY/bashrc"
source "$SYSENV_OUTPUT_DIRECTORY/bashrc"
fi
rm -f "$SYSENV_OUTPUT_DIRECTORY/bashrc"
}
#env-mpi-select() {
# # Do nothing
#}
env-reload
fi