Skip to contentSkip to conversation

dcron: new package

PATCH New Alvaro G. M 3 participants 8 messages Jul 8, 2014 – Jul 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 dcron: new package

---
This patch addresses latests comments from Thomas P.

The package now includes previous considerations about typical use as help text of the Config.in option.

It also solves the fact that it wasn't really installing anything at all, sets busybox as dependency so it can overwrite busybox' cron and crontab files, and modifies /etc/cron.d/system file after installing it so it uses run-parts instead of 'run-cron', a file provided by upstream with the same purpose.

 package/Config.in       |  1 +
 package/dcron/Config.in | 19 +++++++++++++++++++
 package/dcron/dcron.mk  | 31 +++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 package/dcron/Config.in
 create mode 100644 package/dcron/dcron.mk
package/Config.in +1 -0
index 95c0c8b..3f4384f 100644
@@ -1124,6 +1124,7 @@ menu "System tools"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	source "package/bootutils/Config.in"
 	source "package/coreutils/Config.in"
+	source "package/dcron/Config.in"
 endif
 	source "package/cpuload/Config.in"
 	source "package/dsp-tools/Config.in"
package/dcron/Config.in new file +19 -0
new file mode 100644
index 0000000..37182de
@@ -0,0 +1,19 @@
+config BR2_PACKAGE_DCRON
+	bool "dcron"
+	help
+	  dcron is a time-based job scheduler with anacron-like features.
+	  It works as a background daemon that parses individual crontab
+	  files and executes commands on behalf of the users in question.
+
+	  Upon installation, this package will enable a system level cron
+	  daemon with hourly, daily, weekly and monthly crontabs.
+
+	  However, it doesn't allow non root users to create their own
+	  crontab file. This is because /var/spool/cron/crontabs is non
+	  user writable.
+
+	  Typically, a crontab group is created on the system and users
+	  allowed to create crontab entries are added into this group, while
+	  crontab executable is owned by root:crontab with sgid bit enabled.
+
+	  http://www.jimpryor.net/linux/dcron.html
package/dcron/dcron.mk new file +31 -0
new file mode 100644
index 0000000..20dcf23
@@ -0,0 +1,31 @@
+################################################################################
+#
+# dcron
+#
+################################################################################
+
+DCRON_VERSION = 4.5
+DCRON_SITE = http://www.jimpryor.net/linux/releases/
+# The source code does not specify the version of the GPL that is used.
+DCRON_LICENSE = GPL
+
+ifeq ($(BR2_PACKAGE_BUSYBOX),y)
+DCRON_DEPENDENCIES = busybox
+endif
+
+define DCRON_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
+endef
+
+define DCRON_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m0700 $(@D)/crond $(TARGET_DIR)/usr/sbin
+	$(INSTALL) -D -m4755 $(@D)/crontab $(TARGET_DIR)/usr/bin
+	$(INSTALL) -D -m0644 $(@D)/extra/root.crontab $(TARGET_DIR)/etc/cron.d/system
+	# Busybox provides run-parts, so there is no need to use nor install provided run-cron
+	$(SED) 's#/usr/sbin/run-cron#/bin/run-parts#g' $(TARGET_DIR)/etc/cron.d/system
+	$(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
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.0.0
#1 lore raw

PATCH v3 1/1 dcron: new package

Dear Alvaro G. M,

Quoted 1 line · Alvaro G. M

I've applied your patch, but had to make a few changes. Moreover, your package does not install any init script to start crond. Maybe you should cook a followup patch that adds an init script, no?

package/Config.in menu "System tools" · line 1129

Quoted 11 lines
package/Config.in +1 -0
index 95c0c8b..3f4384f 100644
@@ -1124,6 +1124,7 @@ menu "System tools"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	source "package/bootutils/Config.in"
 	source "package/coreutils/Config.in"
+	source "package/dcron/Config.in"
 endif
 	source "package/cpuload/Config.in"

Alphabetic ordering not respected here.

package/dcron/Config.in line 2

Quoted 9 lines
package/Config.in +0 -0
 	source "package/dsp-tools/Config.in"
package/dcron/Config.in new file +2 -0
new file mode 100644
index 0000000..37182de
@@ -0,0 +1,19 @@
+config BR2_PACKAGE_DCRON
+	bool "dcron"

Missing dependency on BR2_USE_MMU, since the package uses the fork() system call.

Quoted 5 lines
package/dcron/Config.in new file +5 -0
+	help
+	  dcron is a time-based job scheduler with anacron-like features.
+	  It works as a background daemon that parses individual crontab
+	  files and executes commands on behalf of the users in question.
+

package/dcron/Config.in line 17

Quoted 10 lines
package/dcron/Config.in new file +10 -0
+	  Upon installation, this package will enable a system level cron
+	  daemon with hourly, daily, weekly and monthly crontabs.
+
+	  However, it doesn't allow non root users to create their own
+	  crontab file. This is because /var/spool/cron/crontabs is non
+	  user writable.
+
+	  Typically, a crontab group is created on the system and users
+	  allowed to create crontab entries are added into this group, while
+	  crontab executable is owned by root:crontab with sgid bit enabled.

Lines too long, I had to rewrap them.

Quoted 8 lines
package/dcron/dcron.mk new file +2 -0
new file mode 100644
index 0000000..20dcf23
@@ -0,0 +1,31 @@
+################################################################################
+#

package/dcron/dcron.mk line 12

Quoted 10 lines
package/dcron/dcron.mk new file +10 -0
+# dcron
+#
+################################################################################
+
+DCRON_VERSION = 4.5
+DCRON_SITE = http://www.jimpryor.net/linux/releases/
+# The source code does not specify the version of the GPL that is used.
+DCRON_LICENSE = GPL
+
+ifeq ($(BR2_PACKAGE_BUSYBOX),y)

I added a short comment above this to explain why we're doing this.

package/dcron/dcron.mk line 22

Quoted 10 lines
package/dcron/dcron.mk new file +10 -0
+DCRON_DEPENDENCIES = busybox
+endif
+
+define DCRON_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
+endef
+
+define DCRON_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m0700 $(@D)/crond $(TARGET_DIR)/usr/sbin
+	$(INSTALL) -D -m4755 $(@D)/crontab $(TARGET_DIR)/usr/bin

On both of those lines, it should have been a full path for the targets.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v3 1/1 dcron: new package

Hi Thomas

Thank you for all your additional fixes. I'll try to make it easier for everyone next time, It seems clear there were too many errors on this small contribution.

I'll take a look at the init script. I hadn't thought about it because I tipically run it directly on inittab.

Regards

Quoted 88 lines · On Tue Jul 15 20:56:33 2014 Thomas Petazzoni…

Dear Alvaro G. M,

Quoted 1 line · Alvaro G. M

I've applied your patch, but had to make a few changes. Moreover, your package does not install any init script to start crond. Maybe you should cook a followup patch that adds an init script, no?

Quoted 11 lines
package/Config.in +0 -0
index 95c0c8b..3f4384f 100644
@@ -1124,6 +1124,7 @@ menu "System tools"

if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
??? source "package/bootutils/Config.in"
??? source "package/coreutils/Config.in"
+??? source "package/dcron/Config.in"
endif
??? source "package/cpuload/Config.in"

Alphabetic ordering not respected here.

package/dcron/Config.in line 2

Quoted 9 lines

??? source "package/dsp-tools/Config.in"

package/dcron/Config.in new file +2 -0
new file mode 100644
index 0000000..37182de
@@ -0,0 +1,19 @@
+config BR2_PACKAGE_DCRON
+??? bool "dcron"

Missing dependency on BR2_USE_MMU, since the package uses the fork() system call.

Quoted 5 lines
package/dcron/Config.in new file +5 -0
+??? help
+??? ?  dcron is a time-based job scheduler with anacron-like features.
+??? ?  It works as a background daemon that parses individual crontab
+??? ?  files and executes commands on behalf of the users in question.
+

package/dcron/Config.in line 17

Quoted 10 lines
package/dcron/Config.in new file +10 -0
+??? ?  Upon installation, this package will enable a system level cron
+??? ?  daemon with hourly, daily, weekly and monthly crontabs.
+
+??? ?  However, it doesn't allow non root users to create their own
+??? ?  crontab file. This is because /var/spool/cron/crontabs is non
+??? ?  user writable.
+
+??? ?  Typically, a crontab group is created on the system and users
+??? ?  allowed to create crontab entries are added into this group, while
+??? ?  crontab executable is owned by root:crontab with sgid bit enabled.

Lines too long, I had to rewrap them.

Quoted 16 lines
package/dcron/dcron.mk new file +9 -0
new file mode 100644
index 0000000..20dcf23
@@ -0,0 +1,31 @@
+################################################################################
+#
+# dcron
+#
+################################################################################
+
+DCRON_VERSION = 4.5
+DCRON_SITE = http://www.jimpryor.net/linux/releases/
+# The source code does not specify the version of the GPL that is

used. +DCRON_LICENSE = GPL

package/dcron/dcron.mk

Quoted 2 lines
package/dcron/dcron.mk new file +2 -0
+
+ifeq ($(BR2_PACKAGE_BUSYBOX),y)

I added a short comment above this to explain why we're doing this.

package/dcron/dcron.mk

Quoted 10 lines
package/dcron/dcron.mk new file +10 -0
+DCRON_DEPENDENCIES = busybox
+endif
+
+define DCRON_BUILD_CMDS
+??? $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
+endef
+
+define DCRON_INSTALL_TARGET_CMDS
+??? $(INSTALL) -D -m0700 $(@D)/crond $(TARGET_DIR)/usr/sbin
+??? $(INSTALL) -D -m4755 $(@D)/crontab $(TARGET_DIR)/usr/bin

On both of those lines, it should have been a full path for the targets.

Quoted 7 lines

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140715/cafba3b2/attachment.html>

#3 lore raw

PATCH v3 1/1 dcron: new package

Dear Alvaro G. M.,

Quoted 3 lines · Alvaro G. M.

Thank you for all your additional fixes. I'll try to make it easier for everyone next time, It seems clear there were too many errors on this small contribution.

That's perfectly fine, we can't expect all contributions from newcomers to immediately be perfect. Your contributions are very welcome.

Quoted 2 lines

I'll take a look at the init script. I hadn't thought about it because I tipically run it directly on inittab.

Ah, ok. Still, I believe an init script would be welcome, as we typically bundle a basic init script in any package that has a daemon, so that it kind of works out of the box for Buildroot users.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 dcron: provide init script

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.

---
 package/dcron/S90dcron | 22 ++++++++++++++++++++++
 package/dcron/dcron.mk |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 package/dcron/S90dcron
package/dcron/S90dcron new file +22 -0
new file mode 100644
index 0000000..c2925fd
@@ -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
package/dcron/dcron.mk +1 -0
index 5174e38..e5a28f2 100644
@@ -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))
Signature · 1 line
2.0.1
#5 lore raw

PATCH 1/1 dcron: provide init script

Alvaro, All,

On 2014-07-17 11:34 +0200, Alvaro G. M spake thusly:

Quoted 46 lines

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.

---
 package/dcron/S90dcron | 22 ++++++++++++++++++++++
 package/dcron/dcron.mk |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 package/dcron/S90dcron
package/dcron/S90dcron new file +22 -0
new file mode 100644
index 0000000..c2925fd
@@ -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
package/dcron/dcron.mk +0 -0
index 5174e38..e5a28f2 100644

package/dcron/dcron.mk define DCRON_INSTALL_TARGET_CMDS · line 30

Quoted 4 lines
package/dcron/dcron.mk +1 -0
@@ -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.

Quoted 10 lines
package/dcron/dcron.mk +0 -0
 endef
 
 $(eval $(generic-package))
Signature · 6 lines
2.0.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#6 lore raw

PATCH 1/1 dcron: provide init script

Dear Yann E. MORIN,

Quoted 2 lines · Yann E. MORIN

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.

Quoted 2 lines

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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#7 lore raw

PATCH 1/1 dcron: provide init script

In reply to Alvaro G. M

Dear Alvaro G. M,

Quoted 6 lines · Alvaro G. M

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.

Quoted 6 lines
---
 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

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com