cron 846 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_set_param respawn
  28. procd_close_instance
  29. }
  30. service_triggers() {
  31. procd_add_validation validate_cron_section
  32. }