diff --git a/files/etc/uci-defaults/82_aredn_ntp_period_migrate b/files/etc/uci-defaults/82_aredn_ntp_period_migrate new file mode 100644 index 00000000..40ddb97a --- /dev/null +++ b/files/etc/uci-defaults/82_aredn_ntp_period_migrate @@ -0,0 +1,18 @@ +#!/bin/sh + +# get current value of ntp_period if any +if [ -e /etc/config.mesh/_setup ] ; then + period=$(grep "ntp_period" /etc/config.mesh/_setup | sed s/^ntp_period\ =\ //) +fi + +# ensure /etc/config.mesh/aredn has ntp values +if [ "$(/sbin/uci -c /etc/config.mesh -q get aredn.@ntp[0])" != "ntp" ]; then + /sbin/uci -c /etc/config.mesh -q add aredn ntp + if [ -n "${period}" ] ; then + /sbin/uci -c /etc/config.mesh -q set aredn.@ntp[0].period="${period}" + else + /sbin/uci -c /etc/config.mesh -q set aredn.@ntp[0].period="daily" + fi + /sbin/uci -c /etc/config.mesh -q commit aredn +fi + diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index 7ad79aa1..28c4aaae 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -669,6 +669,27 @@ if parms.button_save then err("invalid ntp server") end + -- move update-clock to correct location if necessary + if parms.ntp_period == "daily" then + if not nixio.fs.stat("/etc/cron.daily/update-clock") then + if nixio.fs.stat("/etc/cron.hourly/update-clock") then + os.execute("mv /etc/cron.hourly/update-clock /etc/cron.daily/update-clock") + else + err("update-clock script not found") + end + end + elseif parms.ntp_period == "hourly" then + if not nixio.fs.stat("/etc/cron.hourly/update-clock") then + if nixio.fs.stat("/etc/cron.daily/update-clock") then + os.execute("mv /etc/cron.daily/update-clock /etc/cron.hourly/update-clock") + else + err("update-clock script not found") + end + end + else + err("ntp_period not set") + end + if wifi2_enable == "1" then if #wifi2_ssid > 32 then err("LAN Access Point SSID musr be 32 or less characters") @@ -744,6 +765,14 @@ if parms.button_save then end f:close() end + + -- commit new ntp_period value + local cursorm = uci.cursor("/etc/config.mesh") + if parms.ntp_period ~= cursorm:get("aredn", "@ntp[0]", "period") then + cursorm:set("aredn", "@ntp[0]", "period", parms.ntp_period) + cursorm:commit("aredn") + end + aredn_info.set_nvram("node", parms.node); aredn_info.set_nvram("tactical", parms.tactical) aredn_info.set_nvram("config", parms.config) @@ -1384,13 +1413,19 @@ else html.print(" ") end -html.print("LongitudeGrid Square
") -html.print("TimezoneGrid Square
") +html.print("Timezone NTP Server") +html.print("") +html.print("NTP Server   ") +if ntp_period == "daily" or not ntp_period then + html.print("NTP Updates   ") +elseif ntp_period == "hourly" then + html.print("NTP Updates   ") +end hidden[#hidden + 1] = "" hidden[#hidden + 1] = ""