get_modules.sh 1.91 KB
Newer Older
David Hrbáč's avatar
David Hrbáč committed
1
#!/bin/bash
David Hrbáč's avatar
David Hrbáč committed
2
# vim: ai ts=2 sw=2 et sts=2 ft=sh
Easy Build's avatar
Easy Build committed
3

Easy Build's avatar
Easy Build committed
4
PWD="/home/easybuild/git/it4i-modules"
Marek Chrastina's avatar
Marek Chrastina committed
5
cd $PWD || exit 1
easybuild's avatar
easybuild committed
6 7 8

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

Marek Chrastina's avatar
Marek Chrastina committed
14
CLUSTER="$CLUSTERNAME"
easybuild's avatar
easybuild committed
15 16 17 18 19
if [ -z "$CLUSTER" ]; then
   echo "CLUSTERNAME not defined"
   exit 1
fi

Easy Build's avatar
Easy Build committed
20
if [ "$CLUSTER" == "ANSELM" ]; then
easybuild's avatar
easybuild committed
21
  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
22
  ./modules.py > anselm.md
easybuild's avatar
easybuild committed
23
elif [ "$CLUSTER" == "SALOMON" ]; then
easybuild's avatar
easybuild committed
24
  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
25 26 27 28 29 30 31 32
  ./modules.py > salomon.md

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

Easy Build's avatar
Easy Build committed
33
    for dir in "$MODULEBASE"/*
David Hrbáč's avatar
David Hrbáč committed
34 35
    do
      # Exclude following directories
David Hrbáč's avatar
David Hrbáč committed
36
      if [ "$(basename "$dir")" == "all" ]; then
David Hrbáč's avatar
David Hrbáč committed
37 38 39
        continue
      fi
      # In case that it's directory
David Hrbáč's avatar
David Hrbáč committed
40
      if [ -d "$dir" ]; then
David Hrbáč's avatar
David Hrbáč committed
41 42 43
        if [ -z $MODULEPATH ]; then
          MODULEPATH=$dir
        else
easybuild's avatar
easybuild committed
44
          MODULEPATH="$MODULEPATH:$dir"
David Hrbáč's avatar
David Hrbáč committed
45 46 47 48 49 50
        fi
      fi
    done

    export MODULEPATH

Easy Build's avatar
Easy Build committed
51 52 53 54 55 56 57
    if [ "$MODULEBASE" == "/appsuv/modules" ]; then
       ml --show-hidden -t av 2>&1 | awk '{print $1 ",4"}' | grep -v -e '/,\|:' | sort -u > "$FILENAME".csv
       ./modules.py > "$FILENAME".md
    else
       ml --show-hidden -t av 2>&1 | awk '{print $1 ",8"}' | grep -v -e '/,\|:' | sort -u > "$FILENAME".csv
       ./modules.py > "$FILENAME".md
    fi
David Hrbáč's avatar
David Hrbáč committed
58 59

  done
Easy Build's avatar
Easy Build committed
60
elif [ "$CLUSTER" == "DGX" ]; then
Easy Build's avatar
Easy Build committed
61
   ml --show-hidden -t av 2>&1 | awk '{print $1 ",16"}' | grep -v -e '/,\|:' | sort -u > dgx.csv
Easy Build's avatar
Easy Build committed
62
  ./modules.py > dgx.md
easybuild's avatar
easybuild committed
63
elif [ "$CLUSTER" == "BARBORA" ]; then
easybuild_it4i's avatar
easybuild_it4i committed
64
   ml --show-hidden -t av 2>&1 | awk '{print $1 ",32"}' | grep -v -e '/,\|:' | sort -u > barbora.csv
easybuild's avatar
easybuild committed
65
     ./modules.py > barbora.md
Easy Build's avatar
Easy Build committed
66
fi
Easy Build's avatar
Easy Build committed
67

David Hrbáč's avatar
David Hrbáč committed
68
DATE=$(date -R)
easybuild's avatar
easybuild committed
69 70
git diff --exit-code || git commit -am "$DATE"
git push origin master