|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 |
| -if [[ "$#" -lt 1 ]]; then |
4 |
| - printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [--setup]\n" |
5 |
| - printf "Example: bash deploy_monitoring_gcp.sh dev --setup\n" |
6 |
| - printf "Example: bash deploy_monitoring_gcp.sh dev\n" |
| 3 | +function usage() { |
| 4 | + printf "Usage: bash deploy_monitoring_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem} [--setup]\n" |
| 5 | + printf "Example: bash deploy_monitoring_gcp.sh staging gcp \n" |
| 6 | + printf "Example: bash deploy_monitoring_gcp.sh staging gcp --setup\n" |
| 7 | + printf "Example: bash deploy_monitoring_gcp.sh staging onprem \n" |
| 8 | + printf "Example: bash deploy_monitoring_gcp.sh staging onprem --setup\n" |
7 | 9 | printf "\n"
|
8 | 10 | exit
|
| 11 | +} |
| 12 | + |
| 13 | +if [[ $# -lt 2 ]] || [[ $# -gt 3 ]]; then |
| 14 | + usage |
9 | 15 | fi
|
| 16 | + |
10 | 17 | printf "\n[[[[[ deploy_monitoring_gcp.sh ]]]]]\n\n"
|
11 | 18 |
|
12 | 19 | if [[ "$1" = 'dev' ]] || [[ "$1" = 'staging' ]] || [[ "$1" = 'sandbox' ]] || [[ "$1" = 'exp' ]] || [[ "$1" = 'spring' ]] || [[ "$1" = 'summer' ]] || [[ "$1" = 'mainnet' ]]; then
|
|
25 | 32 | printf "SEASON=$SEASON\n"
|
26 | 33 | printf "PROJECT_ID=$PROJECT_ID\n"
|
27 | 34 |
|
28 |
| -GCP_USER="runner" |
29 |
| -printf "GCP_USER=$GCP_USER\n" |
| 35 | +if [[ "$2" = 'gcp' ]] || [[ "$2" = 'onprem' ]]; then |
| 36 | + BLOCKCHAIN_HOSTING="$2" |
| 37 | +else |
| 38 | + printf "Invalid blockchain hosting argument: $2\n" |
| 39 | + exit |
| 40 | +fi |
| 41 | +printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n" |
30 | 42 |
|
31 |
| -OPTIONS="$2" |
| 43 | +OPTIONS="$3" |
32 | 44 | printf "OPTIONS=$OPTIONS\n"
|
33 | 45 |
|
| 46 | +GCP_USER="runner" |
| 47 | +printf "GCP_USER=$GCP_USER\n" |
| 48 | + |
34 | 49 | # Get confirmation.
|
35 | 50 | printf "\n"
|
36 | 51 | read -p "Do you want to proceed for $SEASON? [y/N]: " -n 1 -r
|
|
62 | 77 |
|
63 | 78 | # ssh into each instance, install packages and start up the server
|
64 | 79 | printf "\n\n############################\n# Running monitoring #\n############################\n\n"
|
65 |
| -gcloud compute ssh $MONITORING_TARGET_ADDR --command "cd ./ain-blockchain; . setup_monitoring_gcp.sh $SEASON $GCP_USER && . start_monitoring_gcp.sh" --project $PROJECT_ID --zone $MONITORING_ZONE |
| 80 | +gcloud compute ssh $MONITORING_TARGET_ADDR --command "cd ./ain-blockchain; . setup_monitoring_gcp.sh $SEASON $GCP_USER $BLOCKCHAIN_HOSTING && . start_monitoring_gcp.sh" --project $PROJECT_ID --zone $MONITORING_ZONE |
0 commit comments