Skip to content
Snippets Groups Projects
get_modules.sh 1.38 KiB
Newer Older
David Hrbáč's avatar
David Hrbáč committed
#!/bin/bash
David Hrbáč's avatar
David Hrbáč committed
# vim: ai ts=2 sw=2 et sts=2 ft=sh
Easy Build's avatar
Easy Build committed

Easy Build's avatar
Easy Build committed
PWD="/home/easybuild/git/it4i-modules"
cd $PWD || exit 1
easybuild's avatar
easybuild committed

STATE=$(git fetch 2>&1 | grep master)
if [ ! -z "$STATE" ]; then
David Hrbáč's avatar
David Hrbáč committed
  git pull
  ./get_modules.sh
  exit 0
easybuild's avatar
easybuild committed
fi

CLUSTER="$CLUSTERNAME"
if [ -z "$CLUSTER" ]; then
   echo "CLUSTERNAME not defined"
   exit 1
fi

if [ "$CLUSTER" == "ANSELM" ]; then
  ml --show-hidden -t av 2>&1 | awk '{print $1 ",1"}' | grep -v -e '/,\|:' | sort -u > anselm.csv
David Hrbáč's avatar
David Hrbáč committed
  ./modules.py > anselm.md
elif [ "$CLUSTER" == "SALOMON" ]; then
  ml --show-hidden -t av 2>&1 | awk '{print $1 ",2"}' | grep -v -e '/,\|:' | sort -u > salomon.csv
David Hrbáč's avatar
David Hrbáč committed
  ./modules.py > salomon.md

  for resource in "/appsuv/modules,uv2000" "/apps/phi/modules,phi"
  do
    MODULEBASE=${resource%,*}
    MODULEPATH=""
    FILENAME=${resource#*,}

    for dir in "$MODULEBASE"/*
David Hrbáč's avatar
David Hrbáč committed
    do
      # Exclude following directories
David Hrbáč's avatar
David Hrbáč committed
      if [ "$(basename "$dir")" == "all" ]; then
David Hrbáč's avatar
David Hrbáč committed
        continue
      fi
      # In case that it's directory
David Hrbáč's avatar
David Hrbáč committed
      if [ -d "$dir" ]; then
David Hrbáč's avatar
David Hrbáč committed
        if [ -z $MODULEPATH ]; then
          MODULEPATH=$dir
        else
          MODULEPATH="$MODULEPATH:$dir"
David Hrbáč's avatar
David Hrbáč committed
        fi
      fi
    done

    export MODULEPATH

    ml --show-hidden -t av 2>&1 | awk '{print $1 ",4"}' | grep -v -e '/,\|:' | sort -u > "$FILENAME".csv
David Hrbáč's avatar
David Hrbáč committed
    ./modules.py > "$FILENAME".md

  done
Easy Build's avatar
Easy Build committed
fi
David Hrbáč's avatar
David Hrbáč committed
DATE=$(date -R)
git diff --exit-code || git commit -am "$DATE"
git push origin master