setup.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #/bin/bash
  2. bulkDashboard() {
  3. requiresJsonnet
  4. COUNTER=0
  5. MAX=400
  6. while [ $COUNTER -lt $MAX ]; do
  7. jsonnet -o "dashboards/bulk-testing/dashboard${COUNTER}.json" -e "local bulkDash = import 'dashboards/bulk-testing/bulkdash.jsonnet'; bulkDash + { uid: 'uid-${COUNTER}', title: 'title-${COUNTER}' }"
  8. let COUNTER=COUNTER+1
  9. done
  10. ln -s -f -r ./dashboards/bulk-testing/bulk-dashboards.yaml ../conf/provisioning/dashboards/custom.yaml
  11. }
  12. requiresJsonnet() {
  13. if ! type "jsonnet" > /dev/null; then
  14. echo "you need you install jsonnet to run this script"
  15. echo "follow the instructions on https://github.com/google/jsonnet"
  16. exit 1
  17. fi
  18. }
  19. defaultDashboards() {
  20. ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml
  21. }
  22. defaultDatasources() {
  23. echo "setting up all default datasources using provisioning"
  24. ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml
  25. }
  26. usage() {
  27. echo -e "install.sh\n\tThis script setups dev provision for datasources and dashboards"
  28. echo "Usage:"
  29. echo " bulk-dashboards - create and provisioning 400 dashboards"
  30. echo " no args - provisiong core datasources and dev dashboards"
  31. }
  32. main() {
  33. local cmd=$1
  34. if [[ $cmd == "bulk-dashboards" ]]; then
  35. bulkDashboard
  36. else
  37. defaultDashboards
  38. defaultDatasources
  39. fi
  40. if [[ -z "$cmd" ]]; then
  41. usage
  42. fi
  43. }
  44. main "$@"