diff --git a/contrib/TACC/CollectModuleData4Web.sh b/contrib/TACC/CollectModuleData4Web.sh index 7cec7c049..23e9608e1 100755 --- a/contrib/TACC/CollectModuleData4Web.sh +++ b/contrib/TACC/CollectModuleData4Web.sh @@ -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="" @@ -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