Skip to content

Commit

Permalink
update CollectWebModuleData4Web to use system Lmod
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Aug 8, 2024
1 parent d274f9f commit efd893e
Showing 1 changed file with 36 additions and 54 deletions.
90 changes: 36 additions & 54 deletions contrib/TACC/CollectModuleData4Web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,32 @@
######################################################################
# find ADMIN_DIR

cmd=$0
dir=$(dirname $cmd);
if [ $dir = "." ]; then
dir=$PWD
fi
ADMIN_DIR=$dir
SCRIPT_NAME="${BASH_SOURCE[0]:-${(%):-%x}}"
SCRIPT_DIR=${SCRIPT_NAME%/*}

######################################################################
# find arch.py command if it exists
export PATH=$ADMIN_DIR/bin:$PATH
if command -v arch.py > /dev/null ; then
ARCH=$(arch.py)
else
ARCH=$(arch)

if [ $SCRIPT_DIR = "." ]; then
SCRIPT_DIR=$PWD
fi

########################################################################
# find spider cmd

LMOD_DIR=/opt/apps/lmod/lmod/libexec
if [ ! -x $LMOD_DIR/spider ]; then
echo "$LMOD_DIR/spider command not found!" '-> Quiting!'
exit 1
fi


######################################################################
# Use ~swtools dir if it exists otherwise use ~mclay
########################################################################
# Make sure that $ADMIN_DIR/softwarePage exists

######################################################################
# Find LMOD_DIR in either ~swtools or ~mclay


MCLAY=~mclay
SWTOOLS=~swtools
DIRLIST=( $SWTOOLS/l/pkg/$ARCH/lmod/lmod/libexec/
$SWTOOLS/l/pkg/lmod/lmod/libexec/
$MCLAY/l/pkg/$ARCH/lmod/lmod/libexec/
$MCLAY/l/pkg/lmod/lmod/libexec/
)

for i in "${DIRLIST[@]}"; do
if [ -x $i/spider ]; then
LMOD_DIR=$i
break;
fi
done
ADMIN_DIR=$SCRIPT_DIR
mkdir -p $ADMIN_DIR/softwarePage

######################################################################
# Find LUATOOLS in either ~swtools or ~mclay

DIRLIST=( $SWTOOLS/l/pkg/$ARCH/luatools/luatools
$SWTOOLS/l/pkg/luatools/luatools
$MCLAY/l/pkg/$ARCH/luatools/luatools
$MCLAY/l/pkg/luatools/luatools
)

lua_version=$(lua -e 'print((_VERSION:gsub("Lua ","")))')

for i in "${DIRLIST[@]}"; do
if [ -f $i/share/$lua_version/strict.lua ]; then
LUATOOLS=$i
break;
fi
done

export LUA_PATH="$LUATOOLS/share/$lua_version"'/?.lua;;'
export LUA_CPATH="$LUATOOLS/lib/$lua_version"'/?.so;;'
########################################################################
# find BASE_MODULE_PATH

BASE_MODULE_PATH=""

Expand All @@ -72,9 +40,23 @@ for i in /opt/modulefiles /opt/apps/modulefiles /opt/apps/xsede/modulefiles; do
done
BASE_MODULE_PATH=${BASE_MODULE_PATH%:}

########################################################################
# find name for python3

PYTHON=
for cmd in python3 python python2; do
command -v $cmd > /dev/null
if [ "$?" = 0 ]; then
PYTHON=$cmd
break
fi
done

# Build json software page and make it pretty if possible.

$LMOD_DIR/spider -o softwarePage $BASE_MODULE_PATH > $ADMIN_DIR/softwarePage/softwarePage.old.json

python -mjson.tool $ADMIN_DIR/softwarePage/softwarePage.old.json > $ADMIN_DIR/softwarePage/softwarePage.json 2> /dev/null
$PYTHON -mjson.tool $ADMIN_DIR/softwarePage/softwarePage.old.json > $ADMIN_DIR/softwarePage/softwarePage.json 2> /dev/null
if [ -s $ADMIN_DIR/softwarePage/softwarePage.json ]; then
rm -f $ADMIN_DIR/softwarePage/softwarePage.old.json
else
Expand Down

0 comments on commit efd893e

Please sign in to comment.