docker-compose environment for the entire v.st system
https://v.st/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
#!/bin/bash
|
|
die() { echo >&2 "$@" ; exit 1 ; }
|
|
|
|
DIRNAME="$(dirname $0)"
|
|
cd "$DIRNAME"
|
|
source ../env.production || die "no top level env?"
|
|
source env.production || die "no local env?"
|
|
|
|
BASE="https://$KEYCLOAK_HOSTNAME/realms/$REALM/protocol/openid-connect"
|
|
|
|
if [ ! -r "env.secrets" ]; then
|
|
GRAFANA_CLIENT_SECRET="$(openssl rand -hex 32)"
|
|
GRAFANA_ADMIN_PASSWORD="$(openssl rand -hex 4)"
|
|
|
|
echo "Generating secrets: admin password $GRAFANA_ADMIN_PASSWORD"
|
|
cat <<EOF > env.secrets
|
|
# Do not check in!
|
|
GRAFANA_ADMIN_PASSWORD=$GRAFANA_ADMIN_PASSWORD
|
|
GF_SERVER_ROOT_URL=https://$GRAFANA_HOSTNAME/
|
|
GF_SERVER_DOMAIN=$GRAFANA_HOSTNAME
|
|
GF_AUTH_GENERIC_OAUTH_AUTH_URL=$BASE/auth
|
|
GF_AUTH_GENERIC_OAUTH_TOKEN_URL=$BASE/token
|
|
GF_AUTH_GENERIC_OAUTH_API_URL=$BASE/userinfo
|
|
GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET=$GRAFANA_CLIENT_SECRET
|
|
EOF
|
|
else
|
|
source env.secrets || die "no secret env?"
|
|
fi
|
|
|
|
docker-compose down
|
|
|
|
../keycloak/client-delete 'grafana' || echo "client did not exist?"
|
|
|
|
../keycloak/client-create << EOF || die "unable to create client id"
|
|
{
|
|
"clientId": "grafana",
|
|
"rootUrl": "https://$GRAFANA_HOSTNAME/",
|
|
"adminUrl": "https://$GRAFANA_HOSTNAME/",
|
|
"redirectUris": [ "https://$GRAFANA_HOSTNAME/*" ],
|
|
"webOrigins": [ "https://$GRAFANA_HOSTNAME" ],
|
|
"clientAuthenticatorType": "client-secret",
|
|
"secret": "$GRAFANA_CLIENT_SECRET"
|
|
}
|
|
EOF
|
|
|
|
docker-compose up -d || die "unable to bring up grafana"
|
|
|