sit/check_modules.sh

47 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash -l
#
# Christoph Niethammer <niethammer@hlrs.de>, (c) 2012
#
# TODO:
# - check for proper module unloading
#
failed_modules=()
TMP=${TMP:=/tmp}
logfile="check_modules.log"
module_load_logfile="$TMP/.module_load.log"
module_rm_logfile="$TMP/.module_rm.log"
moduleclass=$1
echo "Module environment check, $(date)" | tee $logfile
for m in $(module av -t $moduleclass 2>&1); do
if [[ $m =~ ^[A-Za-z] ]]; then
m=$(echo $m | sed -e 's/(.*)//')
echo -n "Checking $m ... " | tee -a $logfile
module load $m > $module_load_logfile 2>&1
# check if module was loaded
if module li 2>&1 | grep $m > /dev/null; then
echo "success" | tee -a $logfile
else
echo "failed" | tee -a $logfile
failed_modules=(${failed_modules[@]} $m)
cat $module_load_logfile >> $logfile
fi
module rm $m > $module_rm_logfile 2>&1
module purge 2>/dev/null
rm -f $module_load_logfile
rm -f $module_rm_logfile
fi
done
echo "----------------------------------------"
echo "Summary of failed modules:"
echo "----------------------------------------"
for m in ${failed_modules[@]}; do
echo "$m"
done
echo "----------------------------------------"