grafana: helper script updates

Responding to comments from Ibbc2b116d0c496655a7ce6bb6971e8270ac32647

Make the script run in the grafana .yaml directory so you don't have
working-directory issues.

Put the secrets in this directory and add them to .gitignore

No need for a tty on the loading call

Additionally make it executable, and have a short pause to let the
container start.

Change-Id: Icf0a2cfb1a0f5599704d6c8c9e85345d61884cd5
This commit is contained in:
Ian Wienand 2022-08-03 16:27:01 +10:00
parent 859005d497
commit 3dbb32adb3
2 changed files with 8 additions and 3 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@
*.egg
specs/html
docs-site/html
grafana/grafana-secrets

10
grafana/run-grafana.sh Normal file → Executable file
View File

@ -1,8 +1,9 @@
#!/bin/bash
DOCKER=docker
GRAFYAML_DIR=$(pwd)
SECRETS_DIR=$(pwd)/grafana-secrets
SCRIPT_PATH=$(readlink -f $0)
GRAFYAML_DIR=$(dirname $SCRIPT_PATH)
SECRETS_DIR=${GRAFYAML_DIR}/grafana-secrets
if [ ! -d ${SECRETS_DIR} ]; then
mkdir -p ${SECRETS_DIR}
@ -29,11 +30,14 @@ if [[ $(${DOCKER} ps -f "name=grafana-opendev_test" --format '{{.Names}}') \
docker.io/grafana/grafana-oss
echo "Grafana listening on :3000"
echo "Waiting for startup ..."
sleep 5
echo " ... done"
fi
echo "Reloading dashboards"
${DOCKER} run --rm -t --network=host \
${DOCKER} run --rm --network=host \
-e 'GRAFANA_URL=http://admin:password@localhost:3000' \
-v ${GRAFYAML_DIR}:/grafana:ro \
opendevorg/grafyaml