project-config/grafana/run-grafana.sh
Ian Wienand 859005d497 grafana: add helper script
Add a helper script and assocated README.rst to explain the
interactive development process.

Depends-On: https://review.opendev.org/c/opendev/grafyaml/+/833212
Change-Id: Ibbc2b116d0c496655a7ce6bb6971e8270ac32647
2022-06-30 14:37:01 +10:00

40 lines
1.2 KiB
Bash

#!/bin/bash
DOCKER=docker
GRAFYAML_DIR=$(pwd)
SECRETS_DIR=$(pwd)/grafana-secrets
if [ ! -d ${SECRETS_DIR} ]; then
mkdir -p ${SECRETS_DIR}
echo "password" > ${SECRETS_DIR}/admin_password
echo "admin" > ${SECRETS_DIR}/admin_user
echo "key" > ${SECRETS_DIR}/secret_key
fi
if [[ $(${DOCKER} ps -f "name=grafana-opendev_test" --format '{{.Names}}') \
!= 'grafana-opendev_test' ]]; then
echo "Running Grafana"
${DOCKER} run -d --rm \
--name grafana-opendev_test \
-p 3000:3000 \
-v ${SECRETS_DIR}:/etc/grafana/secrets \
-e GF_AUTH_ANONYMOUS_ENABLED=true \
-e GF_USER_ALLOW_SIGN_UP=false \
-e GF_SECURITY_ADMIN_PASSWORD__FILE=/etc/grafana/secrets/admin_password \
-e GF_SECURITY_ADMIN_USER__FILE=/etc/grafana/secrets/admin_user \
-e GF_SECURITY_SECRET_KEY__FILE=/etc/grafana/secrets/secret_key \
docker.io/grafana/grafana-oss
echo "Grafana listening on :3000"
fi
echo "Reloading dashboards"
${DOCKER} run --rm -t --network=host \
-e 'GRAFANA_URL=http://admin:password@localhost:3000' \
-v ${GRAFYAML_DIR}:/grafana:ro \
opendevorg/grafyaml