setup.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. requiresJsonnet
  21. ln -s -f -r ./dashboards/dev-dashboards/dev-dashboards.yaml ../conf/provisioning/dashboards/custom.yaml
  22. }
  23. defaultDatasources() {
  24. echo "setting up all default datasources using provisioning"
  25. ln -s -f -r ./datasources/default/default.yaml ../conf/provisioning/datasources/custom.yaml
  26. }
  27. usage() {
  28. echo -e "install.sh\n\tThis script installs my basic setup for a debian laptop\n"
  29. echo "Usage:"
  30. echo " bulk-dashboards - create and provisioning 400 dashboards"
  31. echo " default-datasources - provisiong all core datasources"
  32. }
  33. main() {
  34. local cmd=$1
  35. if [[ -z "$cmd" ]]; then
  36. usage
  37. exit 1
  38. fi
  39. if [[ $cmd == "bulk-dashboards" ]]; then
  40. bulkDashboard
  41. elif [[ $cmd == "default-datasources" ]]; then
  42. defaultDatasources
  43. elif [[ $cmd == "default-dashboards" ]]; then
  44. defaultDashboards
  45. else
  46. usage
  47. fi
  48. }
  49. main "$@"