-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·83 lines (66 loc) · 1.36 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/bash
set -e
OPTIND=1
PROVIDER=""
CLUSTER=""
usage()
{
cat << EOF
Usage: build.sh -p PROVIDER -c CLUSTER
Builds a TissueMAPS cluster in the cloud based on a setup file
"./setup/PROVIDER/CLUSTER.yaml".
ARGUMENTS:
-p name of the cloud provider ("sciencecloud", "aws" or "google")
-c name of the cluster
EOF
}
while getopts "c:p:" opt
do
case "$opt" in
c)
CLUSTER=$OPTARG
;;
p) PROVIDER=$OPTARG
;;
\?)
usage
exit 1
;;
:)
echo "Error: Option -$OPTARG requires an argument." >&2
echo
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [[ -z $CLUSTER ]] || [[ -z $PROVIDER ]]
then
echo "Error: Arguments CLUSTER and PROVIDER are required." >&2
echo
usage
exit 1
fi
SCRIPT=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT")
SETUP_DIR="$SCRIPT_DIR/setup/$PROVIDER"
SETUP_FILE="$SETUP_DIR/$CLUSTER.yaml"
if [[ ! -d "$SETUP_DIR" ]]
then
echo "Error: Unknown cloud provider \"$PROVIDER\"" >&2
exit 1
fi
if [[ ! -f "$SETUP_FILE" ]]
then
echo "Error: Unknown cluster \"$CLUSTER\"" >&2
exit 1
fi
BASE_COMMAND () {
cmd=$1
/usr/bin/time --verbose tm_deploy -v vm -s $SETUP_FILE "$cmd" > "$SCRIPT_DIR/log/$PROVIDER/$CLUSTER.$cmd.log" 2>&1;
}
BASE_COMMAND launch
BASE_COMMAND deploy
exit 0