Hello, ntpd have the ability to call a script on three events. This would be useful for other services that need to be notified when the clock was updated, or started/notified after ntp set the system clock (i.e. aiccu, kerberos, winbind).
This is a simple patch that might need improvements. I don't know how much doc should I write inside the scripts as comments as disk is a limited resource. Also, there might be a better path for ntpd-hotplug script (/lib/something/). The patch adds a cmdline parameter "-S script" to ntpd in init.d script (the "-S" function already exists). This script is called whether one of ntpd events occurs: periodic, stratum and step. Periodic is not very useful as cron can do a better job. stratum and step are much more interesting as it detects when the system clock was set or synchronized. Much better than watching logs for these events. ntpd informs the script which event ocurred passing it as the first cmdline argument. The script introduced here just calls "hotplug-call ntp", passing the event as an ENV variable ACTION. This is an example of a ntp hotplug script: #!/bin/sh # # ACTION=(periodic stratum step) # case "$ACTION" in stratum|step) /etc/init.d/myservice try-restart ;; esac PS: I first posted this patch in a trac issue (), but I guess this was the wrong place to go. Signed-off-by: Luiz Angelo Daros de Luca <luizl...@gmail.com> Index: package/base-files/files/usr/sbin/ntpd-hotplug =================================================================== --- package/base-files/files/usr/sbin/ntpd-hotplug (revisao 0) +++ package/base-files/files/usr/sbin/ntpd-hotplug (copia de trabalho) @@ -0,0 +1,3 @@ +#!/bin/sh +# ACTION=(periodic stratum step) +ACTION="$1" /sbin/hotplug-call ntp Index: package/base-files/files/etc/init.d/sysntpd =================================================================== --- package/base-files/files/etc/init.d/sysntpd (revisao 34199) +++ package/base-files/files/etc/init.d/sysntpd (copia de trabalho) @@ -11,6 +11,7 @@ local peers local args="-n" local enable_server + local hotplug_script="/usr/sbin/ntpd-hotplug" config_load system config_get peers ntp server @@ -27,6 +28,10 @@ done fi + if [ -x "$hotplug_script" ]; then + append args "-S $hotplug_script" + fi + if [ "$args" != "-n" ]; then service_start /usr/sbin/ntpd $args fi
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel