entry 777 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 25 26 27 28 29 30 31 32
#!/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 \
  --header 'authorization: Basic YWRtaW46V3hQWVZ4NTM=' \
  --header 'content-type: application/json' \
  --data '{
  "name":"OMI",
  "email":"no@example-com",
  "login":"guest",
  "password":"kiz123"
}'