Skip to content

Commit

Permalink
add quotes to properly handle spaces in user/pass
Browse files Browse the repository at this point in the history
  • Loading branch information
bitodt committed Feb 5, 2024
1 parent 35151fe commit c0ed111
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions post_start/script/set_default_graf_dash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ GRAFANA_USER=${GRAFANA_USER:-admin}
GRAFANA_PASS=${GRAFANA_PASS:-admin}
GRAFANA_HOST=${GRAFANA_HOST:-grafana}
GRAFANA_PORT=${GRAFANA_PORT:-3000}
GRAFANA_URI=${GRAFANA_USER}:${GRAFANA_PASS}@${GRAFANA_HOST}:${GRAFANA_PORT}

echo "Setting Grafana default dashboard..."
DASH_UID="sJUFc-NWk"
DASH_ID=0
for i in 1 2 3 4 5; do
curl -H 'Content-Type: application/json' -X GET "http://${GRAFANA_URI}/api/dashboards/uid/$DASH_UID" && RESP=$(curl -H 'Content-Type: application/json' -X GET "http://${GRAFANA_URI}/api/dashboards/uid/$DASH_UID") && DASH_ID=$( echo "$RESP" | jq '.dashboard.id' ) && break || sleep 15;
curl -H 'Content-Type: application/json' -u "${GRAFANA_USER}:${GRAFANA_PASS}" -X GET http://${GRAFANA_HOST}:${GRAFANA_PORT}/api/dashboards/uid/${DASH_UID} && RESP=$(curl -H 'Content-Type: application/json' -u "${GRAFANA_USER}:${GRAFANA_PASS}" -X GET http://${GRAFANA_HOST}:${GRAFANA_PORT}/api/dashboards/uid/${DASH_UID}) && DASH_ID=$( echo "$RESP" | jq '.dashboard.id' ) && break || sleep 15;
done

for i in 1 2 3 4 5; do
curl -d "{\"homeDashboardId\":$DASH_ID}" -H 'Content-Type: application/json' -X PUT "http://${GRAFANA_URI}/api/org/preferences" && break || sleep 15;
curl -d "{\"homeDashboardId\":${DASH_ID}}" -H 'Content-Type: application/json' -u "${GRAFANA_USER}:${GRAFANA_PASS}" -X PUT http://${GRAFANA_HOST}:${GRAFANA_PORT}/api/org/preferences && break || sleep 15;
done

0 comments on commit c0ed111

Please sign in to comment.