File: update_mirror.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 (40 lines) | stat: -rwxr-xr-x 1,040 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
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "$1" == "" ]; then
  echo "Usage $0: <config-file>"
  exit 1
fi
source ${DIR}/util.sh
source ${DIR}/config.sh $1

GCLOUD="gcloud"

Header "Updating mirror instances..."
i=0
while [ $i -lt ${MIRROR_NUM_REPLICAS} ]; do
  echo "Updating ${MIRROR_MACHINES[${i}]}"
  echo "${MIRROR_META[${i}]}" > /tmp/metadata.${i}

  if ! gcloud compute instances add-metadata \
      ${MIRROR_MACHINES[${i}]} \
      --zone ${MIRROR_ZONES[${i}]} \
      --metadata-from-file google-container-manifest=/tmp/metadata.${i}; then
    echo "Retrying"
    continue
  fi
  

  if ! gcloud compute ssh ${MIRROR_MACHINES[${i}]} \
      --zone ${MIRROR_ZONES[${i}]} \
      --command \
          'sudo docker pull gcr.io/'${PROJECT}'/super_mirror:test &&
           sudo docker kill $(sudo docker ps | grep super_mirror | awk -- "{print \$1}" )'; then
    echo "Retrying"
    continue
  fi

  WaitHttpStatus ${MIRROR_MACHINES[${i}]} ${MIRROR_ZONES[${i}]} /ct/v1/get-sth 200
  i=$(($i + 1))
done;