[OpenWrt-Devel] [PATCH 1/1] use NTP server received via DHCP

Bastian Bittorf bittorf at bluebottle.com
Thu Jan 7 13:49:04 EST 2016


* amine ahd <amine.ahd at gmail.com> [07.01.2016 19:41]:
> ---
>  package/utils/busybox/Makefile             |  3 ++
>  package/utils/busybox/files/sysntpd        | 28 +++++++++++-
>  .../package/utils/busybox/files/sysntpd.hotplug    | 53 ++++++++++++++++++++++

the path for "sysntpd.hotplug" is wrong, it should be:
package/utils/busybox/files/sysntpd.hotplug

> +	local dhcp_ifaces="$(uci -q get system.ntp.dhcp_ifaces)"
> +	[ "$use_dhcp" = 1 ] && {
> +		if [ -z "$dhcp_ifaces" ]; then
> +			local dump=$(ubus call network.interface dump)
> +			ntpservers=$(jsonfilter -s "$dump" -e '$["interface"][*]["data"]["ntpserver"]')
> +		else
> +			for iface in $dhcp_ifaces; do
> +				local status=$(ubus call network.interface.$int status)

please test if your code really runs.
you have renamed "int" to "iface", but not everywhere

> +				[ -n "$ntpserver" ] &&
> +					ntpservers="$ntpservers $ntpserver"

here is a '\' at line end missing, is'nt it?

>  service_triggers()
>  {
>  	procd_add_reload_trigger "system"
> +
>  	procd_add_validation validate_ntp_section
> +
>  }

are these newlines really needed?

> +. /lib/functions.sh
> +. /usr/share/libubox/jshn.sh
> +
> +is_valid_interface() {
> +	local list=$(uci get system.ntp.dhcp_ifaces)
> +	[ -z "$list" ] && return 0;

the ";" is unneeded

> +
> +	case "$list" in
> +		*"$INTERFACE"*)
> +			return 0

please use the spaces like i wrote:
" $list "
and
*" $INTERFACE "*

> +		[ -n "$ntpserver" ] &&
> +			dhcp_ntp_servers="dhcp_ntp_servers $ntpserver"

here is also a "\" missing 

please: before sending this patch to the mailinglist, try
to manually apply it to a fresh git-checkout of openwrt.
after applying, test the resulting files with "shellcheck.net".

bye, bastian.
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list