diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-08 17:07:11 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-08 17:07:11 +0200 |
commit | acbc031a6d1a41fc0a40a4f175bc80a49affc251 (patch) | |
tree | 3f8602291f4bdd1eaa27c802ee49ff879850eebe /modules/luci-base | |
parent | abee9138dec5814b70c9af418c27386a067ba284 (diff) |
luci-base,luci-mod-system: split ubus localtime into get and set call
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rwxr-xr-x | modules/luci-base/root/usr/libexec/rpcd/luci | 16 | ||||
-rw-r--r-- | modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json | 4 |
2 files changed, 16 insertions, 4 deletions
diff --git a/modules/luci-base/root/usr/libexec/rpcd/luci b/modules/luci-base/root/usr/libexec/rpcd/luci index dba6df0cb..55233d6d0 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" diff --git a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json index 6cbaa3d56..a9baef8f9 100644 --- a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json +++ b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json @@ -13,7 +13,7 @@ "read": { "ubus": { "iwinfo": [ "info" ], - "luci": [ "boardjson", "duid_hints", "host_hints", "ifaddrs", "initList", "leases", "leds", "netdevs", "offload_support", "usb" ], + "luci": [ "boardjson", "duid_hints", "host_hints", "ifaddrs", "initList", "getLocaltime", "leases", "leds", "netdevs", "offload_support", "usb" ], "network.device": [ "status" ], "network.interface": [ "dump" ], "network.wireless": [ "status" ], @@ -23,7 +23,7 @@ }, "write": { "ubus": { - "luci": [ "initCall", "localtime", "timezone" ], + "luci": [ "initCall", "setLocaltime", "timezone" ], "uci": [ "add", "apply", "confirm", "delete", "order", "set" ] }, "uci": [ "*" ] |