01_conf_init.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. conf_dir=/etc/graphite-statsd/conf
  3. # auto setup graphite with default configs if /opt/graphite is missing
  4. # needed for the use case when a docker host volume is mounted at an of the following:
  5. # - /opt/graphite
  6. # - /opt/graphite/conf
  7. # - /opt/graphite/webapp/graphite
  8. graphite_dir_contents=$(find /opt/graphite -mindepth 1 -print -quit)
  9. graphite_conf_dir_contents=$(find /opt/graphite/conf -mindepth 1 -print -quit)
  10. graphite_webapp_dir_contents=$(find /opt/graphite/webapp/graphite -mindepth 1 -print -quit)
  11. graphite_storage_dir_contents=$(find /opt/graphite/storage -mindepth 1 -print -quit)
  12. if [[ -z $graphite_dir_contents ]]; then
  13. # git clone -b 1.0.2 --depth 1 https://github.com/graphite-project/graphite-web.git /usr/local/src/graphite-web
  14. cd /usr/local/src/graphite-web && python ./setup.py install
  15. fi
  16. if [[ -z $graphite_storage_dir_contents ]]; then
  17. /usr/local/bin/django_admin_init.exp
  18. fi
  19. if [[ -z $graphite_conf_dir_contents ]]; then
  20. cp -R $conf_dir/opt/graphite/conf/*.conf /opt/graphite/conf/
  21. fi
  22. if [[ -z $graphite_webapp_dir_contents ]]; then
  23. cp $conf_dir/opt/graphite/webapp/graphite/local_settings.py /opt/graphite/webapp/graphite/local_settings.py
  24. fi
  25. # auto setup statsd with default config if /opt/statsd is missing
  26. # needed for the use case when a docker host volume is mounted at an of the following:
  27. # - /opt/statsd
  28. statsd_dir_contents=$(find /opt/statsd -mindepth 1 -print -quit)
  29. if [[ -z $statsd_dir_contents ]]; then
  30. git clone -b v0.7.2 https://github.com/etsy/statsd.git /opt/statsd
  31. cp $conf_dir/opt/statsd/config.js /opt/statsd/config.js
  32. fi