base-files: allow users to delect debug level during boot
[openwrt.git] / package / utils / busybox / files / cron
index 465b1ab..8f54527 100755 (executable)
@@ -3,16 +3,36 @@
 
 START=50
 
 
 START=50
 
-SERVICE_USE_PID=1
+USE_PROCD=1
+PROG=/usr/sbin/crond
+
+validate_cron_section() {
+       uci_validate_section system system "${1}" \
+               'cronloglevel:uinteger'
+}
+
+start_service () {
+       [ -z "$(ls /etc/crontabs/)" ] && return 1
 
 
-start () {
        loglevel=$(uci_get "system.@system[0].cronloglevel")
        loglevel=$(uci_get "system.@system[0].cronloglevel")
-       [ -z "$(ls /etc/crontabs/)" ] && exit 1
+
+       [ -z "${loglevel}" ] || {
+               /sbin/validate_data uinteger "${loglevel}"
+               [ "$?" -eq 0 ] || {
+                       echo "validation failed"
+                       return 1
+               }
+       }
+
        mkdir -p /var/spool/cron
        ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
        mkdir -p /var/spool/cron
        ln -s /etc/crontabs /var/spool/cron/ 2>/dev/null
-       service_start /usr/sbin/crond -c /etc/crontabs -l ${loglevel:-5}
+
+       procd_open_instance
+       procd_set_param command "$PROG" -f -c /etc/crontabs -l ${loglevel:-5}
+       procd_close_instance
 }
 
 }
 
-stop() {
-       service_stop /usr/sbin/crond
+service_triggers()
+{
+       procd_add_validation validate_cron_section
 }
 }