What's new

NTP Daemon for ASUSWRT/Merlin

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Update will usually work, but github's raw cdn can start caching - usually not an issue unless firing rapid requests (the install command and update point to the same URL to pull down the script)

But I updated to 1.0.3, wasn’t fixed, had to run install still. Not a caching issue.


Sent from my iPhone using Tapatalk
 
What is your thinking on hard coded command line arguments?

On the one hand, the most flexible approach is to only specify the config file and leave the rest to the config file. On the other hand, hard coding on the command line avoids unnecessary problems from user error.
Code:
-c /jffs/configs/ntp.conf
Mandatory

-f /opt/var/spool/ntp/ntp.drift
/opt/var/spool/ntp/ntp.drift: No such file or directory
Not sure if the daemon will eventually create?

-s /opt/var/spool/ntp
Stats dir defined but no stats files

-k /opt/etc/ntp
Symmetric keys unlikely to be used

-l /opt/var/spool/ntp/ntp.log"
OK if you insist
I think they come as standard with the ntpd package - the only one I care about is -c, the rest I can remove/change if you prefer
 
But I updated to 1.0.3, wasn’t fixed, had to run install still. Not a caching issue.


Sent from my iPhone using Tapatalk
Install command and update both call:
Code:
/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/jackyaz/ntpdMerlin/master/ntpmerlin.sh" -o "/jffs/scripts/ntpmerlin"
/usr/sbin/curl -fsL --retry 3 "$NTPD_REPO/$NTPD_NAME_LOWER.sh" -o "/jffs/scripts/$NTPD_NAME_LOWER"
with the latter using variables instead of hardcoding
 
Install command and update both call:
Code:
/usr/sbin/curl --retry 3 "https://raw.githubusercontent.com/jackyaz/ntpdMerlin/master/ntpmerlin.sh" -o "/jffs/scripts/ntpmerlin"
/usr/sbin/curl -fsL --retry 3 "$NTPD_REPO/$NTPD_NAME_LOWER.sh" -o "/jffs/scripts/$NTPD_NAME_LOWER"
with the latter using variables instead of hardcoding

But all update does is drag the script down I assume? Not actually run it to make any potential changes to the environment (like creating a dir). Just thinking if any other changes are made in the future relating to where stuff is stored then you’d have to manually run install after update again.


Sent from my iPhone using Tapatalk
 
But all update does is drag the script down I assume? Not actually run it to make any potential changes to the environment (like creating a dir). Just thinking if any other changes are made in the future relating to where stuff is stored then you’d have to manually run install after update again.


Sent from my iPhone using Tapatalk
You're right, when i ported the function from YazFi it would restart firewall (not needed here). 1.0.4 will run the stat generation after update now
 
  • Like
Reactions: JDB
After I removed the previous manual installation, your script worked without a hitch. Very impressed at how quickly you pulled this together. Just waiting for some data to show in the graphs... Thank You Jack!
 
Can I propose next content fo S77ntps
Code:
#!/bin/sh

# shellcheck disable=SC2034

ntpd_precmd(){
    killall -9 -w ntp
    killall -9 -w $PROCS
    $PROCS -gq $ARGS
}

ENABLED=yes
PROCS=ntpd
ARGS="-c /jffs/configs/ntp.conf"
PREARGS=""
PRECMD="ntpd_precmd"
DESC=$PROCS
PATH=/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

. /opt/etc/init.d/rc.func
It will force sync the system time ... but require the main ntpd still be not running
 
@EmeraldDeer fixed for new installs, only -c is specified

(if users want to play with ntp.conf then so be it!)
Suggestion for default ntp.conf
  • Perhaps install script could wget the leap-seconds.list
  • Pool DNS pool.ntp.org has code to reply with geographically close time servers (works, but not consistently)
Code:
#
logfile /opt/var/spool/ntp/ntp.log
driftfile /opt/var/spool/ntp/ntp.drift
leapfile /opt/var/spool/ntp/leap-seconds.list # https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
#
restrict default nomodify notrap nopeer noquery # restrictive default IPv4
restrict -6 default nomodify notrap nopeer noquery # restrictive default IPv6
restrict source nomodify notrap noquery # required for pool directive if using restrictive default permissions
restrict 127.0.0.1 # permissive localhost IPv4
restrict -6 ::1 # permissive localhost IPv6
#
interface ignore wildcard
interface listen br0
#
disable monitor auth stats
#
pool pool.ntp.org iburst
#
EDIT: restrict arguments "limited" and "kod" are not compatible with disable monitor and were removed
 
Last edited:
In case you want to check on your NTP daemon, ntpq -p
Code:
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LaptopPuget     .GPS.            1 u   58   64  377    0.934    0.809   0.425
 pool.ntp.org    .POOL.          16 p    -   64    0    0.000    0.000   0.000
+lx.ujf.cas.cz   .GPS.            1 u    7   64  377  118.716   -0.822   1.181
-199.180.133.100 140.142.2.8      3 u    3   64  377   80.349    4.954   1.166
-ntp3.torix.ca   132.246.11.231   2 u   77  128  377   26.824    5.125   0.890
+84.2.44.19      82.96.64.2       3 u    5   64  377  129.799    2.171   0.492
 eva.aplu.fr     145.238.203.14   2 u   64   64  377  102.420    8.235   1.933
 opus.bloomcount 216.218.254.202  2 u   62   64  377   87.746  -84.267   5.837
 nu.binary.net   128.252.19.1     2 u   63   64  377   62.807   -2.654   0.996
 triton.ellipse. 128.252.19.1     2 u   55   64  377   62.498   -2.226   1.136
Ignore the first line. I have a USB GPS mouse hanging in a window to discipline a Windows NTPD.
 
ntpdMerlin.png
 
@EmeraldDeer fixed for new installs, only -c is specified

(if users want to play with ntp.conf then so be it!)
Sorry, there may be a command line option "-g" that we need. If the time offset is large at startup, ntpd may exit. This would be the case on router reboot.

-g

Normally, ntpd exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that, ntpd will exit with a message to the system log. This option can be used with the -q and -x options. See the tinker command for other options.
 
Last edited:
Sorry, there may be a command line option "-g" that we need. If the time offset is large at startup. ntpd may exit. This would be the case on router reboot.

-g

Normally, ntpd exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that, ntpd will exit with a message to the system log. This option can be used with the -q and -x options. See the tinker command for other options.
Weirdly I'm yet to see that happen, always seems to come up on a reboot. @PeterV suggested similar here: https://www.snbforums.com/threads/ntp-daemon-for-asuswrt-merlin.28041/page-28#post-472751
 
1.0.5 contains some changes to ntp.conf and s77ntpd

Again, unless you update and then install you won’t get these new files.


Sent from my iPhone using Tapatalk
 
Again, unless you update and then install you won’t get these new files.


Sent from my iPhone using Tapatalk
1PM - 9PM shift at work today, so if I have the brainpower when I get home I'll push it then :)
 
1PM - 9PM shift at work today, so if I have the brainpower when I get home I'll push it then :)

No worries.


Sent from my iPhone using Tapatalk
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top