#!/bin/sh function get_system_ntp_option() { local val val="$(uci -q get system.ntp.${1})" echo "${val}" } # migrate system ntp servers to time if uci -q get system.ntp >/dev/null 2>&1; then if [ ! -f "/etc/config/time" ]; then touch /etc/config/time uci -q set time.global="global" uci -q set time.global.enable="1" uci -q set time.client="client" enabled="$(get_system_ntp_option enabled)" if [ -z "${enabled}" ]; then enabled="1" fi uci -q set time.client.enable="$enabled" uci -q set time.client.iburst="1" uci -q set time.client.version="4" uci -q set time.client.peer="0" uci -q set time.client.minpoll="6" uci -q set time.client.maxpoll="10" uci -q set time.client.mode="Unicast" uci -q set time.client.interface="wan" servers="$(get_system_ntp_option server)" if [ -z "${servers}" ]; then servers="ntp1.sth.netnod.se ntp1.gbg.netnod.se" fi for server in $servers; do uci -q add_list time.client.server="${server}" done # DHCP client instance uci -q set time.dhcp_driven="client" uci -q set time.dhcp_driven.enable="0" interface="$(get_system_ntp_option interface)" if [ -n "${interface}" ]; then uci -q set time.dhcp_driven.interface="${interface}" else uci -q set time.dhcp_driven.interface="wan" fi uci -q set time.dhcp_driven.iburst="1" uci -q set time.dhcp_driven.version="4" uci -q set time.dhcp_driven.peer="0" uci -q set time.dhcp_driven.minpoll="6" uci -q set time.dhcp_driven.maxpoll="10" uci -q set time.dhcp_driven.mode="Unicast" # Add timeserver uci -q set time.server="server" uci -q set time.server.enable="$(get_system_ntp_option enable_server)" uci -q set time.server.mode="Unicast" uci -q set time.server.ttl="255" uci -q commit time fi uci -q delete system.ntp uci -q commit system fi