setup-cron.sh 1.2 KB

123456789101112131415161718192021222324
  1. {% macro setup_cron(values) -%}
  2. #!/bin/bash
  3. function check_path() {
  4. [ ! $(ls -A $1) ] && echo "Empty directory found, writing a dummy file at [$1] to trigger indexing" | tee $1/diskover_test.txt
  5. if [ ! -f "/config/crontab" ]; then return; fi
  6. if grep -q "/app/diskover/diskover.py $1" /config/crontab; then
  7. echo "------------------------------------WARNING-----------------------------------"
  8. echo "A crontab entry for [$1] has been found in /config/crontab".
  9. echo "This is no longer needed as it is now handled in the /etc/crontabs/abc file."
  10. echo "Please remove the entry from /config/crontab"
  11. echo "------------------------------------------------------------------------------"
  12. fi
  13. }
  14. check_path /data
  15. {%- for store in values.storage.additional_storage if store.index_data %}
  16. check_path "{{ store.mount_path }}"
  17. {%- endfor %}
  18. echo "Merging {{ values.consts.cron_file_path }} with /etc/crontabs/abc"
  19. cat {{ values.consts.cron_file_path }} /etc/crontabs/abc | sort | uniq > /tmp/crontab-abc
  20. crontab -u abc /tmp/crontab-abc || { echo "Failed to setup crontab"; exit 1; }
  21. echo "Finished merging {{ values.consts.cron_file_path }} with /etc/crontabs/abc"
  22. {%- endmacro %}