061-check-azure-master-is-master.sh 351 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/bash

set -eu

# shellcheck source=/dev/null
source "${BASE}/env_${ENVIRONMENT}"

if echo "select pg_is_in_recovery()" \
  | ssh_remote "$AZURE_MASTER" sudo -u gitlab-psql gitlab-psql -v ON_ERROR_STOP=1 -d postgres -t -A \
  | grep -q 'f'
then
  echo "$AZURE_MASTER is master"
  exit 0
else
  >&2 echo "$AZURE_MASTER is NOT master"
  exit 1
fi