-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from bedroge/update_lmod_cache_script
Add script for updating Lmod caches
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
function echo_green() { | ||
echo -e "\e[32m$1\e[0m" | ||
} | ||
|
||
function echo_red() { | ||
echo -e "\e[31m$1\e[0m" | ||
} | ||
|
||
function error() { | ||
echo_red "ERROR: $1" >&2 | ||
exit 1 | ||
} | ||
|
||
# Check if a stack base dir has been specified | ||
if [ "$#" -ne 1 ]; then | ||
error "usage: $0 <path to main directory of an EESSI stack>" | ||
fi | ||
|
||
stack_base_dir="$1" | ||
|
||
# Check if the given stack base dir exists | ||
if [ ! -d ${stack_base_dir} ] | ||
then | ||
error "${stack_base_dir} does not point to an existing directory!" | ||
fi | ||
|
||
# Check if Lmod's cache update script can be found at the expected location (in the compatibility layer of the given stack) | ||
update_lmod_system_cache_files="${stack_base_dir}/compat/linux/$(uname -m)/usr/share/Lmod/libexec/update_lmod_system_cache_files" | ||
if [ ! -f ${update_lmod_system_cache_files} ] | ||
then | ||
error "expected to find Lmod's cache update script at ${update_lmod_system_cache_files}, but it doesn't exist." | ||
fi | ||
|
||
# Find all subtrees of supported CPU targets by looking for "modules" directories, and taking their parent directory | ||
architectures=$(find ${stack_base_dir}/software/ -maxdepth 5 -type d -name modules -exec dirname {} \;) | ||
|
||
# Create/update the Lmod cache for all architectures | ||
for archdir in ${architectures} | ||
do | ||
lmod_cache_dir="${archdir}/.lmod/cache" | ||
${update_lmod_system_cache_files} -d ${lmod_cache_dir} -t ${lmod_cache_dir}/timestamp ${archdir}/modules/all | ||
exit_code=$? | ||
if [[ ${exit_code} -eq 0 ]]; then | ||
echo_green "Updated the Lmod cache for ${archdir}." | ||
ls -lrt ${lmod_cache_dir} | ||
else | ||
echo_red "Updating the Lmod cache failed for ${archdir}." | ||
exit ${exit_code} | ||
fi | ||
done |