-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathsetup-instance.sh
executable file
·47 lines (41 loc) · 2.08 KB
/
setup-instance.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
#!/usr/bin/env bash
# Setup a GCE instance.
set -o errexit # Exit on first command error.
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
. $SCRIPT_DIR/../../handle-paths.sh
if [ -z "$GCPKMS_GCLOUD" ] || [ -z "$GCPKMS_PROJECT" ] || [ -z "$GCPKMS_ZONE" ] || [ -z "$GCPKMS_INSTANCENAME" ]; then
echo "Please set the following required environment variables"
echo " GCPKMS_GCLOUD to the path of the gcloud binary"
echo " GCPKMS_PROJECT to the GCP project"
echo " GCPKMS_ZONE to the GCP zone"
echo " GCPKMS_INSTANCENAME to the GCE instance name"
exit 1
fi
echo "Copying setup-gce-instance.sh to GCE instance ($GCPKMS_INSTANCENAME) ... begin"
# Copy files to test. Use "-p" to preserve execute mode.
$GCPKMS_GCLOUD compute scp $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/remote-scripts/setup-gce-instance.sh "$GCPKMS_INSTANCENAME":~ \
--zone $GCPKMS_ZONE \
--project $GCPKMS_PROJECT \
--scp-flag="-p"
echo "Copying setup-gce-instance.sh to GCE instance ($GCPKMS_INSTANCENAME) ... end"
echo "Running setup-gce-instance.sh on GCE instance ($GCPKMS_INSTANCENAME) ... begin"
$GCPKMS_GCLOUD compute ssh "$GCPKMS_INSTANCENAME" \
--zone $GCPKMS_ZONE \
--project $GCPKMS_PROJECT \
--command "./setup-gce-instance.sh"
echo "Exit code of test-script is: $?"
echo "Running setup-gce-instance.sh on GCE instance ($GCPKMS_INSTANCENAME) ... end"
echo "Copying start-mongodb.sh to GCE instance ($GCPKMS_INSTANCENAME) ... begin"
# Copy files to test. Use "-p" to preserve execute mode.
$GCPKMS_GCLOUD compute scp $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/remote-scripts/start-mongodb.sh "$GCPKMS_INSTANCENAME":~ \
--zone $GCPKMS_ZONE \
--project $GCPKMS_PROJECT \
--scp-flag="-p"
echo "Copying start-mongodb.sh to GCE instance ($GCPKMS_INSTANCENAME) ... end"
echo "Running start-mongodb.sh on GCE instance ($GCPKMS_INSTANCENAME) ... begin"
$GCPKMS_GCLOUD compute ssh "$GCPKMS_INSTANCENAME" \
--zone $GCPKMS_ZONE \
--project $GCPKMS_PROJECT \
--command "./start-mongodb.sh"
echo "Exit code of test-script is: $?"
echo "Running start-mongodb.sh on GCE instance ($GCPKMS_INSTANCENAME) ... end"