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