busybox: add option to install ntp startup script
PATCH 1/1 busybox: add option to install ntp startup script
--- package/busybox/Config.in | 6 ++++++ package/busybox/S49ntp | 34 ++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 15 +++++++++++++++ package/busybox/ntp.conf | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 package/busybox/S49ntp create mode 100644 package/busybox/ntp.conf
package/busybox/Config.in +6 -0
@@ -26,6 +26,12 @@ config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS Show packages in menuconfig that are potentially also provided by busybox. +config BR2_PACKAGE_BUSYBOX_NTP + bool "Install the ntp startup script" + help + Install the ntp daemon startup script, that by default operates in + client-only mode and synchronizes the system time with pool.ntp.org. + config BR2_PACKAGE_BUSYBOX_WATCHDOG bool "Install the watchdog daemon startup script" help
package/busybox/S49ntp new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/sh +# +# Start ntp daemon (in client mode) +# + +start() { + echo -n "Starting ntpd: " + start-stop-daemon -S -b -q -m -p /var/run/ntpd.pid --exec /usr/sbin/ntpd -- -n + echo "OK" +} + +stop() { + echo -n "Stopping ntpd: " + start-stop-daemon -K -q -p /var/run/ntpd.pid + echo "OK" +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?
package/busybox/busybox.mk +15 -0
@@ -151,6 +151,19 @@ define BUSYBOX_INSTALL_WATCHDOG_SCRIPT endef endif +ifeq ($(BR2_PACKAGE_BUSYBOX_NTP),y) +define BUSYBOX_SET_NTP + $(call KCONFIG_ENABLE_OPT,CONFIG_NTPD,$(BUSYBOX_BUILD_CONFIG)) + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_NTPD_CONF,$(BUSYBOX_BUILD_CONFIG)) +endef +define BUSYBOX_INSTALL_NTP_SCRIPT + $(INSTALL) -D -m 0644 package/busybox/ntp.conf \ + $(TARGET_DIR)/etc/ntp.conf + $(INSTALL) -D -m 0755 package/busybox/S49ntp \ + $(TARGET_DIR)/etc/init.d/S49ntp +endef +endif + # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links. define BUSYBOX_NOCLOBBER_INSTALL
@@ -166,6 +179,7 @@ define BUSYBOX_KCONFIG_FIXUP_CMDS $(BUSYBOX_SET_CRYPT_SHA) $(BUSYBOX_INTERNAL_SHADOW_PASSWORDS) $(BUSYBOX_SET_INIT) + $(BUSYBOX_SET_NTP) $(BUSYBOX_SET_WATCHDOG) endef
@@ -188,6 +202,7 @@ endef define BUSYBOX_INSTALL_INIT_SYSV $(BUSYBOX_INSTALL_MDEV_SCRIPT) + $(BUSYBOX_INSTALL_NTP_SCRIPT) $(BUSYBOX_INSTALL_LOGGING_SCRIPT) $(BUSYBOX_INSTALL_WATCHDOG_SCRIPT) endef
package/busybox/ntp.conf new file +2 -0
@@ -0,0 +1,2 @@ +server 0.pool.ntp.org +server 1.pool.ntp.org
Signature · 1 line
2.1.4
PATCH 1/1 busybox: add option to install ntp startup script
Quoted 15 lines · Floris Bos
Signed-off-by Floris Bos <[email protected]>--- package/busybox/Config.in | 6 ++++++ package/busybox/S49ntp | 34 ++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 15 +++++++++++++++ package/busybox/ntp.conf | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 package/busybox/S49ntp create mode 100644 package/busybox/ntp.confpackage/busybox/Config.in +0
-0
package/busybox/Config.in config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS · line 34
Quoted 9 lines
package/busybox/Config.in +6
-0@@ -26,6 +26,12 @@ config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS Show packages in menuconfig that are potentially also provided by busybox. +config BR2_PACKAGE_BUSYBOX_NTP + bool "Install the ntp startup script" + help + Install the ntp daemon startup script, that by default operates in + client-only mode and synchronizes the system time with pool.ntp.org. +
Should this section be wrapped in an "if BR2_PACKAGE_NTP" / "endif" block? I guess there's no point showing the option if the NTP package is not selected.
On a higher level, wouldn't it make sense to add this option to the NTP package itself, instead of busybox? Especially because NTP is not the only ntp client supported by busybox, there's also chrony. Ideally that should also have an option for default setup and startup script, just like the this patch aims to do for ntp.
Quoted 89 lines
package/busybox/Config.in +0
-0config BR2_PACKAGE_BUSYBOX_WATCHDOG bool "Install the watchdog daemon startup script" helppackage/busybox/S49ntp new file +34
-0@@ -0,0 +1,34 @@ +#!/bin/sh +# +# Start ntp daemon (in client mode) +# + +start() { + echo -n "Starting ntpd: " + start-stop-daemon -S -b -q -m -p /var/run/ntpd.pid --exec /usr/sbin/ntpd -- -n + echo "OK" +} + +stop() { + echo -n "Stopping ntpd: " + start-stop-daemon -K -q -p /var/run/ntpd.pid + echo "OK" +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?package/busybox/busybox.mk +15
-0@@ -151,6 +151,19 @@ define BUSYBOX_INSTALL_WATCHDOG_SCRIPT endef endif +ifeq ($(BR2_PACKAGE_BUSYBOX_NTP),y) +define BUSYBOX_SET_NTP + $(call KCONFIG_ENABLE_OPT,CONFIG_NTPD,$(BUSYBOX_BUILD_CONFIG)) + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_NTPD_CONF,$(BUSYBOX_BUILD_CONFIG)) +endef +define BUSYBOX_INSTALL_NTP_SCRIPT + $(INSTALL) -D -m 0644 package/busybox/ntp.conf \ + $(TARGET_DIR)/etc/ntp.conf + $(INSTALL) -D -m 0755 package/busybox/S49ntp \ + $(TARGET_DIR)/etc/init.d/S49ntp +endef +endif + # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links. define BUSYBOX_NOCLOBBER_INSTALL@@ -166,6 +179,7 @@ define BUSYBOX_KCONFIG_FIXUP_CMDS $(BUSYBOX_SET_CRYPT_SHA) $(BUSYBOX_INTERNAL_SHADOW_PASSWORDS) $(BUSYBOX_SET_INIT) + $(BUSYBOX_SET_NTP) $(BUSYBOX_SET_WATCHDOG) endef@@ -188,6 +202,7 @@ endef define BUSYBOX_INSTALL_INIT_SYSV $(BUSYBOX_INSTALL_MDEV_SCRIPT) + $(BUSYBOX_INSTALL_NTP_SCRIPT) $(BUSYBOX_INSTALL_LOGGING_SCRIPT) $(BUSYBOX_INSTALL_WATCHDOG_SCRIPT) endefpackage/busybox/ntp.conf new file +0
-0
package/busybox/ntp.conf line 2
Quoted 2 lines
package/busybox/ntp.conf new file +2
-0@@ -0,0 +1,2 @@ +server 0.pool.ntp.org +server 1.pool.ntp.org
Isn't 2 servers too few in general? If there's a default conf, maybe use the same setup as the NTP Pool project page's simple setup at
http://www.pool.ntp.org/en/use.html
package/busybox/ntp.conf new file +6 -0
@@ -0,0 +1,6 @@ +driftfile /var/lib/ntp/ntp.drift + +server 0.pool.ntp.org +server 1.pool.ntp.org +server 2.pool.ntp.org +server 3.pool.ntp.org
Cheers,
Greg
PATCH 1/1 busybox: add option to install ntp startup script
Quoted 137 lines · Gergely Imreh
Quoted 15 lines · Floris Bos
Signed-off-by Floris Bos <[email protected]>--- package/busybox/Config.in | 6 ++++++ package/busybox/S49ntp | 34 ++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 15 +++++++++++++++ package/busybox/ntp.conf | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 package/busybox/S49ntp create mode 100644 package/busybox/ntp.confpackage/busybox/Config.in +0
-0package/busybox/Config.in config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS · line 34
Quoted 9 lines
package/busybox/Config.in +6
-0@@ -26,6 +26,12 @@ config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS Show packages in menuconfig that are potentially also provided by busybox. +config BR2_PACKAGE_BUSYBOX_NTP + bool "Install the ntp startup script" + help + Install the ntp daemon startup script, that by default operates in + client-only mode and synchronizes the system time with pool.ntp.org. +Should this section be wrapped in an "if
BR2_PACKAGE_NTP" / "endif" block? I guess there's no point showing the option if the NTP package is not selected.On a higher level, wouldn't it make sense to add this option to the NTP package itself, instead of busybox? Especially because NTP is not the only ntp client supported by busybox, there's also chrony. Ideally that should also have an option for default setup and startup script, just like the this patch aims to do for ntp.
Quoted 89 lines
package/busybox/Config.in +0
-0config BR2_PACKAGE_BUSYBOX_WATCHDOG bool "Install the watchdog daemon startup script" helppackage/busybox/S49ntp new file +34
-0@@ -0,0 +1,34 @@ +#!/bin/sh +# +# Start ntp daemon (in client mode) +# + +start() { + echo -n "Starting ntpd: " + start-stop-daemon -S -b -q -m -p /var/run/ntpd.pid --exec /usr/sbin/ntpd -- -n + echo "OK" +} + +stop() { + echo -n "Stopping ntpd: " + start-stop-daemon -K -q -p /var/run/ntpd.pid + echo "OK" +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?package/busybox/busybox.mk +15
-0@@ -151,6 +151,19 @@ define BUSYBOX_INSTALL_WATCHDOG_SCRIPT endef endif +ifeq ($(BR2_PACKAGE_BUSYBOX_NTP),y) +define BUSYBOX_SET_NTP + $(call KCONFIG_ENABLE_OPT,CONFIG_NTPD,$(BUSYBOX_BUILD_CONFIG)) + $(call KCONFIG_ENABLE_OPT,CONFIG_FEATURE_NTPD_CONF,$(BUSYBOX_BUILD_CONFIG)) +endef +define BUSYBOX_INSTALL_NTP_SCRIPT + $(INSTALL) -D -m 0644 package/busybox/ntp.conf \ + $(TARGET_DIR)/etc/ntp.conf + $(INSTALL) -D -m 0755 package/busybox/S49ntp \ + $(TARGET_DIR)/etc/init.d/S49ntp +endef +endif + # Enable "noclobber" in install.sh, to prevent BusyBox from overwriting any # full-blown versions of apps installed by other packages with sym/hard links. define BUSYBOX_NOCLOBBER_INSTALL@@ -166,6 +179,7 @@ define BUSYBOX_KCONFIG_FIXUP_CMDS $(BUSYBOX_SET_CRYPT_SHA) $(BUSYBOX_INTERNAL_SHADOW_PASSWORDS) $(BUSYBOX_SET_INIT) + $(BUSYBOX_SET_NTP) $(BUSYBOX_SET_WATCHDOG) endef@@ -188,6 +202,7 @@ endef define BUSYBOX_INSTALL_INIT_SYSV $(BUSYBOX_INSTALL_MDEV_SCRIPT) + $(BUSYBOX_INSTALL_NTP_SCRIPT) $(BUSYBOX_INSTALL_LOGGING_SCRIPT) $(BUSYBOX_INSTALL_WATCHDOG_SCRIPT) endefpackage/busybox/ntp.conf new file +0
-0package/busybox/ntp.conf line 2
Quoted 2 lines
package/busybox/ntp.conf new file +2
-0@@ -0,0 +1,2 @@ +server 0.pool.ntp.org +server 1.pool.ntp.orgIsn't 2 servers too few in general? If there's a default conf, maybe use the same setup as the NTP Pool project page's simple setup at
http://www.pool.ntp.org/en/use.html
package/busybox/ntp.conf line 6
Quoted 6 lines
package/busybox/ntp.conf new file +6
-0@@ -0,0 +1,6 @@ +driftfile /var/lib/ntp/ntp.drift + +server 0.pool.ntp.org +server 1.pool.ntp.org +server 2.pool.ntp.org +server 3.pool.ntp.org
Also, after trying a test build, the ntp.conf script from this patch is overwritten by package/ntp/ntpd.etc.conf anyways, so would not actually show up on the target (I'm assuming that the ntp package is selected).
Cheers,
Greg
PATCH 1/1 busybox: add option to install ntp startup script
Hi Greg,
Quoted 13 lines · Gergely Imreh
Quoted 13 lines
package/busybox/ntp.conf line 2
Quoted 8 lines
package/busybox/ntp.conf new file +2
-0@@ -0,0 +1,2 @@ +server 0.pool.ntp.org +server 1.pool.ntp.orgIsn't 2 servers too few in general? If there's a default conf, maybe use the same setup as the NTP Pool project page's simple setup at
http://www.pool.ntp.org/en/use.html
Quoted 14 lines
package/busybox/ntp.conf line 6
Quoted 9 lines
package/busybox/ntp.conf new file +6
-0@@ -0,0 +1,6 @@ +driftfile /var/lib/ntp/ntp.drift + +server 0.pool.ntp.org +server 1.pool.ntp.org +server 2.pool.ntp.org +server 3.pool.ntp.orgAlso, after trying a test build, the ntp.conf script from this patch is overwritten by
package/ntp/ntpd.etc.confanyways, so would not actually show up on the target (I'm assuming that the ntp package is selected).
That's the intended behaviour. Whenever you select a package that implements the same functionality as a Busybox applet, the selected package takes precedence. For this reason any such package should list busybox in its <PKG>_DEPENDENCIES. I see that the ntp package doesn't do so, but I think it's a bug. I'll send a patch shortly.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/1 busybox: add option to install ntp startup script
In reply to Gergely ImrehHi,
Quoted 29 lines · Gergely Imreh
Quoted 15 lines · Floris Bos
Signed-off-by Floris Bos <[email protected]>--- package/busybox/Config.in | 6 ++++++ package/busybox/S49ntp | 34 ++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 15 +++++++++++++++ package/busybox/ntp.conf | 2 ++ 4 files changed, 57 insertions(+)create mode 100644 package/busybox/S49ntp
create mode 100644package/busybox/ntp.confpackage/busybox/Config.in +0
-0package/busybox/Config.in config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS · line 34
Quoted 9 lines
package/busybox/Config.in +6
-0@@ -26,6 +26,12 @@ config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS Show packages in menuconfig that are potentially also provided by busybox. +config BR2_PACKAGE_BUSYBOX_NTP + bool "Install the ntp startup script" + help + Install the ntp daemon startup script, that by default operates in + client-only mode and synchronizes the system time with pool.ntp.org. +Should this section be wrapped in an "if
BR2_PACKAGE_NTP" / "endif" block? I guess there's no point showing the option if the NTP package is not selected.
Quoted 2 lines
On a higher level, wouldn't it make sense to add this option to the NTP package itself, instead of busybox?
Note that this patch is about enabling the ntpd applet included in Busybox, as a light-weight alternative to the full blown standalone NTP package.
So no, it does not depend on BR2_PACKAGE_NTP.
BR2_PACKAGE_NTP and BR2_PACKAGE_OPENNTPD already have startup scripts of their own.
But if you just want your device to retrieve the time because it lacks a RTC (as opposed to playing server and providing the time to others), installing those is overkill in my opinion.
Quoted 2 lines
Especially because NTP is not the only ntp client supported by busybox, there's also chrony.
Ideally that should also have an option for default setup and startup
script, just like the this patch aims to do for ntp.
Chrony is a standalone buildroot package, and not an applet provided by busybox.
Doesn't it install a startup script implicity, if you select it in buildroot?
Quoted 7 lines
package/busybox/Config.in line 2
Quoted 4 lines
package/busybox/Config.in +3
-0+++ b/package/busybox/ntp.conf@@ -0,0 +1,2 @@ +server 0.pool.ntp.org +server 1.pool.ntp.orgIsn't 2 servers too few in general? If there's a default conf, maybe use the same setup as the NTP Pool project page's simple setup at
http://www.pool.ntp.org/en/use.html
It is the same we currently have for the standalone ntp package in package/ntp/ntpd.etc.conf
Am open to change that, but I do think the standalone ntp config should be changed too then.
Signature · 3 lines
Yours sincerely, Floris Bos
PATCH 1/1 busybox: add option to install ntp startup script
Quoted 46 lines · Floris Bos
Hi,
Quoted 34 lines · Gergely Imreh
Quoted 23 lines · Floris Bos
Signed-off-by Floris Bos <[email protected]>--- package/busybox/Config.in | 6 ++++++ package/busybox/S49ntp | 34 ++++++++++++++++++++++++++++++++++ package/busybox/busybox.mk | 15 +++++++++++++++ package/busybox/ntp.conf | 2 ++ 4 files changed, 57 insertions(+)create mode 100644 package/busybox/S49ntp
create mode 100644package/busybox/ntp.confpackage/busybox/Config.in +4
-0@@ -26,6 +26,12 @@ config BR2_PACKAGE_BUSYBOX_SHOW_OTHERS Show packages in menuconfig that are potentially also provided by busybox. +config BR2_PACKAGE_BUSYBOX_NTP + bool "Install the ntp startup script" + help + Install the ntp daemon startup script, that by default operatesQuoted 4 lines
in
+ client-only mode and synchronizes the system time with
pool.ntp.org.
+Should this section be wrapped in an "if
BR2_PACKAGE_NTP" / "endif" block? I guess there's no point showing the option if the NTP package is not selected.Quoted 2 lines
On a higher level, wouldn't it make sense to add this option to the NTP package itself, instead of busybox?
Note that this patch is about enabling the ntpd applet included in Busybox, as a light-weight alternative to the full blown standalone NTP package. So no, it does not depend on
BR2_PACKAGE_NTP.
Quoted 5 lines
BR2_PACKAGE_NTPandBR2_PACKAGE_OPENNTPDalready have startup scripts of their own.
But if you just want your device to retrieve the time because it lacks a RTC (as opposed to playing server and providing the time to others), installing those is overkill in my opinion.
Ah, sorry, it's my bad then! It wasn't really obvious to me that there's an NTP within busybox.
Quoted 23 lines
Quoted 7 lines
Especially because NTP is not the only ntp client supported by busybox,
there's also chrony.Ideally that should also have an option for default setup and startup script, just like the this patch aims to do for ntp.
Chrony is a standalone buildroot package, and not an applet provided by busybox.
Doesn't it install a startup script implicity, if you select it in buildroot?Quoted 8 lines
package/busybox/Config.in line 2
Quoted 4 lines
+++
b/package/busybox/ntp.confpackage/busybox/Config.in +2
-0@@ -0,0 +1,2 @@ +server 0.pool.ntp.org +server 1.pool.ntp.orgIsn't 2 servers too few in general? If there's a default conf, maybe use the same setup as the NTP Pool project page's simple setup at
http://www.pool.ntp.org/en/use.html
Quoted 4 lines
It is the same we currently have for the standalone ntp package in
package/ntp/ntpd.etc.conf
Am open to change that, but I do think the standalone ntp config should be changed too then.
Looking at package/ntp/ntpd.etc.conf and it's just similar, but not the same. It's similar in the sense that it only uses two servers, but different that "iburst" is not used, and no other settings are in there.
By the way, one more data point for choosing more than 2 NTP servers:
the RedHat knowledgebase also recommends at least 4:
https://access.redhat.com/solutions/58025
Quoted 6 lines
--
Yours sincerely,Floris Bos