github.com/bartle-stripe/trillian@v1.2.1/storage/mysql/kubernetes/resetdb.sh (about)

     1  #!/bin/bash -e
     2  
     3  readonly TRILLIAN_PATH=$(go list -f '{{.Dir}}' github.com/google/trillian)
     4  
     5  # Pick a random port between 2000 - 34767. Will fail if unlucky and the port is in use.
     6  readonly port=$((${RANDOM} + 2000))
     7  kubectl port-forward "galera-0" "${port}:3306" >/dev/null &
     8  proxy_pid=$!
     9  
    10  options_file=$(mktemp)
    11  chmod 0600 "${options_file}"
    12  echo > ${options_file} <<EOF
    13  [client]
    14  host=localhost
    15  port=${port}
    16  user=root
    17  password="$(kubectl get secrets mysql-credentials --template '{{index .data "root-password"}}' | base64 -d)"
    18  EOF
    19  
    20  "${TRILLIAN_PATH}/scripts/resetdb.sh" --defaults-extra-file="${options_file}"
    21  
    22  rm "${options_file}"
    23  
    24  kill "${proxy_pid}"
    25  wait "${proxy_pid}" 2>/dev/null
    26