run.sh 711 Bytes
Newer Older
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
1
2
3
4
5
6
#!/usr/bin/env bash

set -e

#
# ./this_script [my_args...] tmp_script stage_name
Pape's avatar
Pape committed
7
8
#                            \________/
#                        This has to be run!
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
9
10
#

Pape's avatar
Pape committed
11
12
13
14
15
16
17
BLUE='\033[0;34m'
NC='\033[0m' # No Color

script="${@: -2:1}"
runStage="${@: -1}"
echo "run stage: $runStage"

18
19
module load git

Pape's avatar
Pape committed
20
21
22
23
24
25
26
27
28
if [[ "$runStage" == "build_script" ]]; then

    scriptPath="$(dirname $script)"
    scriptPathInTmp==$(echo "$scriptPath" | cut -c 5-)  # cuts off /tmp in the front
    scriptName="$(basename $script)"
    newDir="/home/pape58/runner-wd$scriptPathInTmp"

    mkdir -p "$newDir"
    cp "$script" "$newDir"
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
29

Pape's avatar
Pape committed
30
31
32
33
34
    echo -e "${BLUE}##### SRUN #####${NC}"
    srun "$newDir/$scriptName"
else
    "$script"
fi
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
35
36

exit 0