setup.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. bulkDashboard() {
  3. requiresJsonnet
  4. COUNTER=0
  5. MAX=400
  6. while [ $COUNTER -lt $MAX ]; do
  7. jsonnet -o "bulk-dashboards/dashboard${COUNTER}.json" -e "local bulkDash = import 'bulk-dashboards/bulkdash.jsonnet'; bulkDash + { uid: 'uid-${COUNTER}', title: 'title-${COUNTER}' }"
  8. let COUNTER=COUNTER+1
  9. done
  10. ln -s -f -r ./bulk-dashboards/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. devDashboards() {
  20. echo -e "\xE2\x9C\x94 Setting up all dev dashboards using provisioning"
  21. ln -s -f ../../../devenv/dashboards.yaml ../conf/provisioning/dashboards/dev.yaml
  22. }
  23. devDatasources() {
  24. echo -e "\xE2\x9C\x94 Setting up all dev datasources using provisioning"
  25. ln -s -f ../../../devenv/datasources.yaml ../conf/provisioning/datasources/dev.yaml
  26. }
  27. usage() {
  28. echo -e "\n"
  29. echo "Usage:"
  30. echo " bulk-dashboards - create and provisioning 400 dashboards"
  31. echo " no args - provisiong core datasources and dev dashboards"
  32. }
  33. main() {
  34. echo -e "------------------------------------------------------------------"
  35. echo -e "This script setups provisioning for dev datasources and dashboards"
  36. echo -e "------------------------------------------------------------------"
  37. echo -e "\n"
  38. local cmd=$1
  39. if [[ $cmd == "bulk-dashboards" ]]; then
  40. bulkDashboard
  41. else
  42. devDashboards
  43. devDatasources
  44. fi
  45. if [[ -z "$cmd" ]]; then
  46. usage
  47. fi
  48. }
  49. main "$@"