From acbc031a6d1a41fc0a40a4f175bc80a49affc251 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 8 Jul 2019 17:07:11 +0200 Subject: luci-base,luci-mod-system: split ubus localtime into get and set call Signed-off-by: Jo-Philipp Wich --- modules/luci-base/root/usr/libexec/rpcd/luci | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'modules/luci-base/root/usr/libexec/rpcd') diff --git a/modules/luci-base/root/usr/libexec/rpcd/luci b/modules/luci-base/root/usr/libexec/rpcd/luci index dba6df0cb9..55233d6d0a 100755 --- a/modules/luci-base/root/usr/libexec/rpcd/luci +++ b/modules/luci-base/root/usr/libexec/rpcd/luci @@ -37,14 +37,26 @@ local methods = { end }, - localtime = { + getLocaltime = { call = function(args) return { localtime = os.time() } end }, + setLocaltime = { + args = { localtime = 0 }, + call = function(args) + local sys = require "luci.sys" + local date = os.date("*t", args.localtime) + if date then + sys.call("date -s '%04d-%02d-%02d %02d:%02d:%02d' >/dev/null" %{ date.year, date.month, date.day, date.hour, date.min, date.sec }) + sys.call("/etc/init.d/sysfixtime restart >/dev/null") + end + return { localtime = args.localtime } + end + }, + timezone = { - args = { zonename = "UTC" }, call = function(args) local util = require "luci.util" local zones = require "luci.sys.zoneinfo" -- cgit v1.2.3