diff mbox

[1/1] dcron: provide init script

Message ID 1405589648-26777-1-git-send-email-alvaro.gamez@hazent.com
State Accepted
Headers show

Commit Message

Alvaro Gamez Machado July 17, 2014, 9:34 a.m. UTC
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.

Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
---
 package/dcron/S90dcron | 22 ++++++++++++++++++++++
 package/dcron/dcron.mk |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 package/dcron/S90dcron

Comments

Yann E. MORIN July 17, 2014, 4:58 p.m. UTC | #1
Alvaro, All,

On 2014-07-17 11:34 +0200, Alvaro G. M spake thusly:
> 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.
> 
> Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
> ---
>  package/dcron/S90dcron | 22 ++++++++++++++++++++++
>  package/dcron/dcron.mk |  1 +
>  2 files changed, 23 insertions(+)
>  create mode 100644 package/dcron/S90dcron
> 
> diff --git a/package/dcron/S90dcron b/package/dcron/S90dcron
> new file mode 100644
> index 0000000..c2925fd
> --- /dev/null
> +++ b/package/dcron/S90dcron
> @@ -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
> diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
> index 5174e38..e5a28f2 100644
> --- a/package/dcron/dcron.mk
> +++ b/package/dcron/dcron.mk
> @@ -27,6 +27,7 @@ define DCRON_INSTALL_TARGET_CMDS
>  	$(INSTALL) -d -m0755 $(TARGET_DIR)/var/spool/cron/crontabs \
>  	        $(TARGET_DIR)/etc/cron.daily $(TARGET_DIR)/etc/cron.hourly \
>  	        $(TARGET_DIR)/etc/cron.monthly $(TARGET_DIR)/etc/cron.weekly
> +	$(INSTALL) -m 0755 -D package/dcron/S90dcron $(TARGET_DIR)/etc/init.d/S90dcron

This should be in a DCRON_INSTALL_INIT_SYSV macro, see:
    http://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_with_specific_build_systems

Also provide the systemd unit file (if it is available in the package!)
with the DCRON_INSTALL_INIT_SYSTEMD macro.

Regards,
Yann E. MORIN.

>  endef
>  
>  $(eval $(generic-package))
> -- 
> 2.0.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni July 17, 2014, 6:35 p.m. UTC | #2
Dear Yann E. MORIN,

On Thu, 17 Jul 2014 18:58:14 +0200, Yann E. MORIN wrote:

> This should be in a DCRON_INSTALL_INIT_SYSV macro, see:
>     http://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_with_specific_build_systems

I'll fix this when applying.

> Also provide the systemd unit file (if it is available in the package!)
> with the DCRON_INSTALL_INIT_SYSTEMD macro.

I don't think there's a systemd unit file for dcron.

However, I remember there was one in the recently added upmpdcli
package, but since I don't know much about systemd, I didn't had
support for it. If anyone feel like adding support for upmpdcli systemd
unit file, don't hesitate to do it :-)

Cheers,

Thomas
Thomas Petazzoni July 17, 2014, 7 p.m. UTC | #3
Dear Alvaro G. M,

On Thu, 17 Jul 2014 11:34:08 +0200, Alvaro G. M wrote:
> 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.
> 
> Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
> ---
>  package/dcron/S90dcron | 22 ++++++++++++++++++++++
>  package/dcron/dcron.mk |  1 +
>  2 files changed, 23 insertions(+)
>  create mode 100644 package/dcron/S90dcron

Thanks, applied with the change suggested by Yann.

Thomas
diff mbox

Patch

diff --git a/package/dcron/S90dcron b/package/dcron/S90dcron
new file mode 100644
index 0000000..c2925fd
--- /dev/null
+++ b/package/dcron/S90dcron
@@ -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
diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
index 5174e38..e5a28f2 100644
--- a/package/dcron/dcron.mk
+++ b/package/dcron/dcron.mk
@@ -27,6 +27,7 @@  define DCRON_INSTALL_TARGET_CMDS
 	$(INSTALL) -d -m0755 $(TARGET_DIR)/var/spool/cron/crontabs \
 	        $(TARGET_DIR)/etc/cron.daily $(TARGET_DIR)/etc/cron.hourly \
 	        $(TARGET_DIR)/etc/cron.monthly $(TARGET_DIR)/etc/cron.weekly
+	$(INSTALL) -m 0755 -D package/dcron/S90dcron $(TARGET_DIR)/etc/init.d/S90dcron
 endef
 
 $(eval $(generic-package))