2006-10-04 20:05:48 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2011-11-07 22:58:39 +00:00
|
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
|
|
|
|
2007-05-10 10:38:53 +00:00
|
|
|
START=50
|
2006-06-27 00:36:13 +00:00
|
|
|
|
2013-07-11 17:00:30 +00:00
|
|
|
USE_PROCD=1
|
|
|
|
PROG=/usr/sbin/crond
|
|
|
|
|
2013-11-25 08:34:55 +00:00
|
|
|
validate_cron_section() {
|
|
|
|
uci_validate_section system system "${1}" \
|
|
|
|
'cronloglevel:uinteger'
|
|
|
|
}
|
|
|
|
|
2018-06-14 01:21:11 +00:00
|
|
|
start_service() {
|
2013-07-11 17:00:30 +00:00
|
|
|
[ -z "$(ls /etc/crontabs/)" ] && return 1
|
2011-01-28 12:50:10 +00:00
|
|
|
|
2016-10-14 18:32:22 +00:00
|
|
|
loglevel="$(uci_get "system.@system[0].cronloglevel")"
|
2013-11-25 08:34:55 +00:00
|
|
|
|
|
|
|
[ -z "${loglevel}" ] || {
|
2014-10-02 19:47:33 +00:00
|
|
|
/sbin/validate_data uinteger "${loglevel}" 2>/dev/null
|
2013-11-25 08:34:55 +00:00
|
|
|
[ "$?" -eq 0 ] || {
|
|
|
|
echo "validation failed"
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-04 20:05:48 +00:00
|
|
|
mkdir -p /var/spool/cron
|
2010-03-21 17:16:41 +00:00
|
|
|
ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
|
2006-10-04 20:05:48 +00:00
|
|
|
|
2013-07-11 17:00:30 +00:00
|
|
|
procd_open_instance
|
2024-12-01 11:07:05 +00:00
|
|
|
procd_set_param command "$PROG" -f -c /etc/crontabs -l "${loglevel:-7}"
|
2018-06-14 01:21:11 +00:00
|
|
|
for crontab in /etc/crontabs/*; do
|
|
|
|
procd_set_param file "$crontab"
|
|
|
|
done
|
2020-11-09 10:43:10 +00:00
|
|
|
procd_set_param respawn
|
2013-07-11 17:00:30 +00:00
|
|
|
procd_close_instance
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
2013-11-25 08:34:55 +00:00
|
|
|
|
2018-06-14 01:21:11 +00:00
|
|
|
service_triggers() {
|
2013-11-25 08:34:55 +00:00
|
|
|
procd_add_validation validate_cron_section
|
|
|
|
}
|