Skip to content

Commit

Permalink
chrony: add ntp hotplug provider script
Browse files Browse the repository at this point in the history
When the service is started, wait for the clock to be synchronized for
up to 5 minutes and provide the stratum action once for ntp hotplug
scripts.

Signed-off-by: Miroslav Lichvar <[email protected]>
  • Loading branch information
mlichvar authored and hnyman committed Dec 18, 2023
1 parent 4fce398 commit 9b6bf46
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/chrony/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ define Package/chrony/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/chronyd $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/chronyc $(1)/usr/bin
$(INSTALL_BIN) ./files/chrony.ntp-hotplug $(1)/usr/sbin/chrony-hotplug
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/chrony
Expand Down
6 changes: 6 additions & 0 deletions net/chrony/files/chrony.ntp-hotplug
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
# Wait for sync for up to 5 minutes and notify other services

/usr/bin/chronyc waitsync 300 1 0.0 1 || exit 0

ubus call hotplug.ntp call '{ "env": [ "ACTION=stratum" ] }'
5 changes: 5 additions & 0 deletions net/chrony/files/chronyd.init
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
START=15
USE_PROCD=1
PROG=/usr/sbin/chronyd
HOTPLUG=/usr/sbin/chrony-hotplug
CONFIGFILE=/etc/chrony/chrony.conf
INCLUDEFILE=/var/etc/chrony.d/10-uci.conf
RTCDEVICE=/dev/rtc0
Expand Down Expand Up @@ -79,6 +80,10 @@ start_service() {
procd_set_param file $INCLUDEFILE
procd_close_instance

procd_open_instance
procd_set_param command $HOTPLUG
procd_close_instance

config_load chrony
mkdir -p $(dirname $INCLUDEFILE)

Expand Down

0 comments on commit 9b6bf46

Please sign in to comment.