1
0

cron 821 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. START=50
  4. USE_PROCD=1
  5. PROG=/usr/sbin/crond
  6. validate_cron_section() {
  7. uci_validate_section system system "${1}" \
  8. 'cronloglevel:uinteger'
  9. }
  10. start_service() {
  11. [ -z "$(ls /etc/crontabs/)" ] && return 1
  12. loglevel="$(uci_get "system.@system[0].cronloglevel")"
  13. [ -z "${loglevel}" ] || {
  14. /sbin/validate_data uinteger "${loglevel}" 2>/dev/null
  15. [ "$?" -eq 0 ] || {
  16. echo "validation failed"
  17. return 1
  18. }
  19. }
  20. mkdir -p /var/spool/cron
  21. ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
  22. procd_open_instance
  23. procd_set_param command "$PROG" -f -c /etc/crontabs -l "${loglevel:-5}"
  24. for crontab in /etc/crontabs/*; do
  25. procd_set_param file "$crontab"
  26. done
  27. procd_close_instance
  28. }
  29. service_triggers() {
  30. procd_add_validation validate_cron_section
  31. }