setup.sh 1.5 KB

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