entry 779 Bytes
Newer Older
Simon Volpert's avatar
Simon Volpert committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

fetchstatus() {
  curl \
    -o /dev/null \
    --silent \
    --head \
    --write-out '%{http_code}' \
    "http://grafana:3000/login"
}

echo "Waitung until Grafana is ready..."

urlstatus=$(fetchstatus)          # initialize to actual value before we sleep even once
until [ "$urlstatus" = 200 ]; do  # until our result is success...
  sleep 1                         # wait a second...
  urlstatus=$(fetchstatus)        # then poll again.
  echo $urlstatus
done

echo "Grafana is ready"

curl --request POST \
  --url http://grafana:3000/api/admin/users \
Simon Volpert's avatar
Simon Volpert committed
25
  --header 'authorization: Basic ${GRAFANA_AUTH_TOKEN}' \
Simon Volpert's avatar
Simon Volpert committed
26
27
  --header 'content-type: application/json' \
  --data '{
Simon Volpert's avatar
Simon Volpert committed
28
  "name":"Guest",
Simon Volpert's avatar
Simon Volpert committed
29
30
  "email":"no@example-com",
  "login":"guest",
Simon Volpert's avatar
Simon Volpert committed
31
  "password":"guest"
Simon Volpert's avatar
Simon Volpert committed
32
}'