File: update_mirror_vm_image.sh

package info (click to toggle)
golang-github-google-certificate-transparency 0.0~git20160709.0.0f6e3d1~ds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 5,676 kB
  • sloc: cpp: 35,278; python: 11,838; java: 1,911; sh: 1,885; makefile: 950; xml: 520; ansic: 225
file content (49 lines) | stat: -rwxr-xr-x 1,634 bytes parent folder | download
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
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "$1" == "" ]; then
  echo "Usage: $0 <config.sh file>"
  exit 1;
fi
source ${DIR}/config.sh $1
source ${DIR}/util.sh

set -e
GCLOUD="gcloud"

${GCLOUD} config set project ${PROJECT}

MANIFEST=/tmp/mirror_container.yaml

Header "Recreating mirror instances..."
for i in `seq 0 $((${MIRROR_NUM_REPLICAS} - 1))`; do
  echo "Deleting instance ${MIRROR_MACHINES[$i]}"
  set +e
   ${GCLOUD} compute instances delete -q ${MIRROR_MACHINES[${i}]} \
      --zone ${MIRROR_ZONES[${i}]} \
      --keep-disks data
  set -e

  echo "${MIRROR_META[${i}]}" > ${MANIFEST}.${i}

  echo "Recreating instance ${MIRROR_MACHINES[$i]}"
  ${GCLOUD} compute instances create -q ${MIRROR_MACHINES[${i}]} \
      --zone ${MIRROR_ZONES[${i}]} \
      --machine-type ${MIRROR_MACHINE_TYPE} \
      --image container-vm \
      --disk name=${MIRROR_DISKS[${i}]},mode=rw,boot=no,auto-delete=no \
      --tags mirror-node \
      --scopes "monitoring,storage-ro,compute-ro,logging-write" \
      --metadata-from-file startup-script=${DIR}/node_init.sh,google-container-manifest=${MANIFEST}.${i}

  gcloud compute instance-groups unmanaged add-instances \
      "mirror-group-${MIRROR_ZONES[${i}]}" \
      --zone ${MIRROR_ZONES[${i}]} \
      --instances ${MIRROR_MACHINES[${i}]} &

  set +e
  echo "Waiting for instance ${MIRROR_MACHINES[${i}]}..."
  WaitForStatus instances ${MIRROR_MACHINES[${i}]} ${MIRROR_ZONES[${i}]} RUNNING
  echo "Waiting for mirror service on ${MIRROR_MACHINES[${i}]}..."
  WaitHttpStatus ${MIRROR_MACHINES[${i}]} ${MIRROR_ZONES[${i}]} /ct/v1/get-sth 200
  set -e
done