8
8
# - optionally executing a site-specific post installation julia script, using the project where preferences were set (e.g, to modify preferences or to create an uenv view equivalent to the activation script).
9
9
10
10
11
- # Define info, error, cleanup, check functions and julia call for setting preferences
11
+ # Define log, info, error, cleanup, check functions and julia call for setting preferences
12
+
13
+ export JUHPC_SETUP_INSTALLLOG=" ./hpc_setup_install.log" # must be defined at the very beginning
12
14
13
15
export JUHPC=" \e[1;34m[\e[0m \e[1;35mJ\e[0m\e[1;32mU\e[0m\e[1;31mH\e[0m\e[1;31mP\e[0m\e[1;31mC\e[0m\e[1;34m:\e[0m"
14
16
@@ -103,20 +105,35 @@ progress_bar() {
103
105
}
104
106
105
107
106
- # Assign passed arguments to environment variables
108
+ # Assign positional arguments and set default values for keyword arguments
107
109
108
110
export JUHPC_SETUP_INSTALLDIR=" $1 "
109
111
export JULIAUP_INSTALLDIR=" $2 "
110
- export JUHPC_POST_INSTALL_JL=" $3 "
112
+ export JUHPC_POST_INSTALL_JL=" "
113
+ export JUHPC_VERBOSE=0
114
+
115
+
116
+ # Check positional arguments
117
+
118
+ check_var " JUHPC_SETUP_INSTALLDIR" " JULIAUP_INSTALLDIR"
119
+ if [[ " $JULIAUP_INSTALLDIR " == " $JUHPC_SETUP_INSTALLDIR " ]]; then
120
+ error " JULIAUP_INSTALLDIR and JUHPC_SETUP_INSTALLDIR cannot have the same value."
121
+ fi
122
+ check_dir " $JUHPC_SETUP_INSTALLDIR "
111
123
112
124
113
- # Check/set environment variables for logging and defining verbosity of output
125
+ # Parse and check the keyword arguments
114
126
115
- export JUHPC_SETUP_INSTALLLOG=" $JUHPC_SETUP_INSTALLDIR /setup_install.log" # Need to be defined at the very beginning
127
+ shift 2
128
+ for arg in " $@ " ; do
129
+ case $arg in
130
+ postinstall=* ) export JUHPC_POST_INSTALL_JL=" ${arg#* =} " ;;
131
+ verbose=* ) export JUHPC_VERBOSE=" ${arg#* =} " ;;
132
+ * ) error " Unknown argument: $arg " ;;
133
+ esac
134
+ done
116
135
117
- if [[ -z " $JUHPC_VERBOSE " ]]; then
118
- export JUHPC_VERBOSE=0
119
- elif ! [[ " $JUHPC_VERBOSE " =~ ^[0-2]$ ]]; then
136
+ if ! [[ " $JUHPC_VERBOSE " =~ ^[0-2]$ ]]; then
120
137
error " JUHPC_VERBOSE must be between 0 and 2."
121
138
fi
122
139
@@ -133,21 +150,16 @@ else
133
150
error " Neither /dev/shm nor /tmp directories exist. Cannot set TMP environment variable."
134
151
fi
135
152
136
- mkdir -p " $TMP " || { error " failed to create directory: $TMP " ; }
137
153
export TMP_JULIAUP_ROOTDIR=" $TMP /juliaup"
138
154
139
155
140
156
# Start installation
141
157
142
158
print_logo
143
159
info " Starting installation of HPC setup for juliaup, julia and HPC key packages requiring system libraries..."
144
- check_var " JULIAUP_INSTALLDIR" " JUHPC_SETUP_INSTALLDIR"
145
- check_dir " $JUHPC_SETUP_INSTALLDIR "
146
- mkdir -p " $JUHPC_SETUP_INSTALLDIR " || { error " failed to create directory: $JUHPC_SETUP_INSTALLDIR " ; }
147
160
148
- if [[ " $JULIAUP_INSTALLDIR " == " $JUHPC_SETUP_INSTALLDIR " ]]; then
149
- error " JULIAUP_INSTALLDIR and JUHPC_SETUP_INSTALLDIR cannot have the same value."
150
- fi
161
+ mkdir -p " $TMP " || { error " failed to create directory: $TMP " ; }
162
+ mkdir -p " $JUHPC_SETUP_INSTALLDIR " || { error " failed to create directory: $JUHPC_SETUP_INSTALLDIR " ; }
151
163
152
164
153
165
# Download and install julia in /tmp using juliaup
@@ -333,9 +345,7 @@ info "... done: activate script created."
333
345
334
346
if [ -n " ${JUHPC_POST_INSTALL_JL} " ]; then
335
347
info " Executing site-specific post-installation julia script (using the project where preferences were set)..."
336
- progress_bar 1 # Initialize progress bar.
337
- julia --project=" $JULIA_PREFDIR " " $JUHPC_POST_INSTALL_JL "
338
- progress_bar 100 # Finalize progress bar.
348
+ julia --project=" $JULIA_PREFDIR " " $JUHPC_POST_INSTALL_JL " 2>&1 | tee -a " $JUHPC_SETUP_INSTALLLOG "
339
349
info " ... done: post-installation script completed."
340
350
fi
341
351
344
354
345
355
cleanup
346
356
mv " $JULIA_PREFDIR /Manifest.toml" " $JULIA_PREFDIR /Manifest.toml.bak" || { error " failed to move Manifest.toml in $JULIA_PREFDIR " ; }
357
+ mv " $JUHPC_SETUP_INSTALLLOG " " $JUHPC_SETUP_INSTALLDIR /" || { error " failed to move $JUHPC_SETUP_INSTALLLOG to $JUHPC_SETUP_INSTALLDIR " ; }
347
358
348
359
info " ... The installation of the HPC setup for juliaup, julia and HPC key packages is complete.\n\n"
0 commit comments