diff mbox

openntpd: add SysV initscript and user

Message ID 1402486395-15125-1-git-send-email-gustavo@zacarias.com.ar
State Accepted
Commit fb6c286697c5f579759fd279ea421667755700ef
Headers show

Commit Message

Gustavo Zacarias June 11, 2014, 11:33 a.m. UTC
Add the _ntp user that the daemon requires to work in any way.
Add a SysV-style initscript as well, but not with '-s' (set time
immediately after startup) because it can make the boot process stall
for a few seconds if there's no proper network connectivity/dns setup.
Make ntp and openntpd mutually exclusive since they overstep each other.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
---
 package/openntpd/Config.in   |  4 ++--
 package/openntpd/S49ntp      | 25 +++++++++++++++++++++++++
 package/openntpd/openntpd.mk |  9 +++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100755 package/openntpd/S49ntp

Comments

Yann E. MORIN June 22, 2014, 5:23 p.m. UTC | #1
Gustavo, All

On 2014-06-11 08:33 -0300, Gustavo Zacarias spake thusly:
> Add the _ntp user that the daemon requires to work in any way.
> Add a SysV-style initscript as well, but not with '-s' (set time
> immediately after startup) because it can make the boot process stall
> for a few seconds if there's no proper network connectivity/dns setup.
> Make ntp and openntpd mutually exclusive since they overstep each other.
> 
> Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
[--SNIP--]
> diff --git a/package/openntpd/openntpd.mk b/package/openntpd/openntpd.mk
> index f0e4f19..0fe6179 100644
> --- a/package/openntpd/openntpd.mk
> +++ b/package/openntpd/openntpd.mk
> @@ -10,4 +10,13 @@ OPENNTPD_CONF_OPT = --with-builtin-arc4random --disable-strip
>  OPENNTPD_LICENSE = MIT-like, BSD-2c, BSD-3c
>  OPENNTPD_LICENSE_FILES = LICENCE
>  
> +define OPENNTPD_INSTALL_INIT_SYSV
> +	$(INSTALL) -m 0755 -D package/openntpd/S49ntp \
> +		$(TARGET_DIR)/etc/init.d/S49ntp
> +endef
> +
> +define OPENNTPD_USERS
> +_ntp -1 _ntp -1 * - - - Network Time Protocol daemon

Any reason why you name the user and group with a leading '_' ?

Regards,
Yann E. MORIN.

> +endef
> +
>  $(eval $(autotools-package))
> -- 
> 1.8.5.5
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Gustavo Zacarias June 22, 2014, 10:32 p.m. UTC | #2
On 06/22/2014 02:23 PM, Yann E. MORIN wrote:

> Any reason why you name the user and group with a leading '_' ?

Because the code says so, and it's not configurable.
The group just to keep consistency.
Regards.
Yann E. MORIN June 22, 2014, 10:37 p.m. UTC | #3
Gustavo, All,

On 2014-06-22 19:32 -0300, Gustavo Zacarias spake thusly:
> On 06/22/2014 02:23 PM, Yann E. MORIN wrote:
> 
> > Any reason why you name the user and group with a leading '_' ?
> 
> Because the code says so, and it's not configurable.
> The group just to keep consistency.

Ok, that should be noted as a comment above the user definition, I
guess.

Regards,
Yann E. MORIN.
Gustavo Zacarias June 22, 2014, 10:43 p.m. UTC | #4
On 06/22/2014 07:37 PM, Yann E. MORIN wrote:

>>> Any reason why you name the user and group with a leading '_' ?
>>
>> Because the code says so, and it's not configurable.
>> The group just to keep consistency.
> 
> Ok, that should be noted as a comment above the user definition, I
> guess.

Why?
We don't document these details for systemd or other packages, why
should we here?
I think the _USERS variable is explicit enough as documentation.
Regards.
Arnout Vandecappelle June 23, 2014, 4:38 p.m. UTC | #5
On 23/06/14 00:43, Gustavo Zacarias wrote:
> On 06/22/2014 07:37 PM, Yann E. MORIN wrote:
> 
>>>> Any reason why you name the user and group with a leading '_' ?
>>>
>>> Because the code says so, and it's not configurable.
>>> The group just to keep consistency.
>>
>> Ok, that should be noted as a comment above the user definition, I
>> guess.
> 
> Why?
> We don't document these details for systemd or other packages, why
> should we here?
> I think the _USERS variable is explicit enough as documentation.

 Also, it is explicit in the commit message. So I agree that the patch is OK as
is. Well, putting a comment wouldn't hurt of course.

 So anyway:

Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>


 Regards,
 Arnout

> Regards.
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
Peter Korsgaard July 8, 2014, 12:18 p.m. UTC | #6
>>>>> "Gustavo" == Gustavo Zacarias <gustavo@zacarias.com.ar> writes:

 > Add the _ntp user that the daemon requires to work in any way.
 > Add a SysV-style initscript as well, but not with '-s' (set time
 > immediately after startup) because it can make the boot process stall
 > for a few seconds if there's no proper network connectivity/dns setup.
 > Make ntp and openntpd mutually exclusive since they overstep each other.

 > Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>

Committed, thanks.
diff mbox

Patch

diff --git a/package/openntpd/Config.in b/package/openntpd/Config.in
index 4dd9a29..a8ef807 100644
--- a/package/openntpd/Config.in
+++ b/package/openntpd/Config.in
@@ -1,7 +1,7 @@ 
 config BR2_PACKAGE_OPENNTPD
 	bool "openntpd"
-	# fork()
-	depends on BR2_USE_MMU
+	depends on BR2_USE_MMU # fork ()
+	depends on !BR2_PACKAGE_NTP # conflicting binaries
 	help
 	  OpenNTPD is an easy to use implementation of the Network Time
 	  Protocol. It provides the ability to sync the local clock
diff --git a/package/openntpd/S49ntp b/package/openntpd/S49ntp
new file mode 100755
index 0000000..99e0f68
--- /dev/null
+++ b/package/openntpd/S49ntp
@@ -0,0 +1,25 @@ 
+#!/bin/sh
+
+[ -x /usr/sbin/ntpd ] || exit 0
+[ -f /etc/ntpd.conf ] || exit 0
+
+case "$1" in
+	start)
+		echo -n "Starting openntpd: "
+		start-stop-daemon -S -x /usr/sbin/ntpd
+		[ $? == 0 ] && echo "OK" || echo "FAIL"
+		;;
+	stop)
+		echo -n "Stopping openntpd: "
+		start-stop-daemon -K -x /usr/sbin/ntpd
+		[ $? == 0 ] && echo "OK" || echo "FAIL"
+		;;
+	restart)
+		"$0" stop
+		sleep 1
+		"$0" start
+		;;
+	*)
+		echo "Usage: $0 {start|stop|restart}"
+		;;
+esac
diff --git a/package/openntpd/openntpd.mk b/package/openntpd/openntpd.mk
index f0e4f19..0fe6179 100644
--- a/package/openntpd/openntpd.mk
+++ b/package/openntpd/openntpd.mk
@@ -10,4 +10,13 @@  OPENNTPD_CONF_OPT = --with-builtin-arc4random --disable-strip
 OPENNTPD_LICENSE = MIT-like, BSD-2c, BSD-3c
 OPENNTPD_LICENSE_FILES = LICENCE
 
+define OPENNTPD_INSTALL_INIT_SYSV
+	$(INSTALL) -m 0755 -D package/openntpd/S49ntp \
+		$(TARGET_DIR)/etc/init.d/S49ntp
+endef
+
+define OPENNTPD_USERS
+_ntp -1 _ntp -1 * - - - Network Time Protocol daemon
+endef
+
 $(eval $(autotools-package))