dcron: provide init script
authorAlvaro G. M <alvaro.gamez@hazent.com>
Thu, 17 Jul 2014 09:34:08 +0000 (11:34 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Thu, 17 Jul 2014 18:59:46 +0000 (20:59 +0200)
dcron doesn't create a pid file, so we run it in foreground but make
start-stop-daemon create the pidfile and move the daemon to background.

Give it a number greater than exim's init script, so job output email
can be sent.

[Thomas: as suggested by Yann E. Morin, use DCRON_INSTALL_INIT_SYSV.]

Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/dcron/S90dcron [new file with mode: 0644]
package/dcron/dcron.mk

diff --git a/package/dcron/S90dcron b/package/dcron/S90dcron
new file mode 100644 (file)
index 0000000..c2925fd
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+case "$1" in
+       start)
+               echo -n "Starting cron ... "
+               start-stop-daemon -S -q -m -b -p /var/run/dcron.pid --exec /usr/sbin/crond -- -f
+               echo "done."
+               ;;
+       stop)
+               echo -n "Stopping cron ..."
+               start-stop-daemon -K -q -p /var/run/dcron.pid
+               echo "done."
+               ;;
+       restart)
+               $0 stop
+               sleep 1
+               $0 start
+               ;;
+       *)
+               echo "usage: $0 {start|stop|restart}"
+               ;;
+esac
index 5174e38ad0f0852d31a26cad236978f456c92533..8892b9692b02bab89454fdea85546587c14a59ab 100644 (file)
@@ -29,4 +29,8 @@ define DCRON_INSTALL_TARGET_CMDS
                $(TARGET_DIR)/etc/cron.monthly $(TARGET_DIR)/etc/cron.weekly
 endef
 
+define DCRON_INSTALL_INIT_SYSV
+       $(INSTALL) -D -m 0755 package/dcron/S90dcron $(TARGET_DIR)/etc/init.d/S90dcron
+endef
+
 $(eval $(generic-package))