function index()
local fs = require "nixio.fs"
- entry({"admin", "system", "system"}, cbi("admin_system/system"), _("System"), 1)
- entry({"admin", "system", "clock_status"}, post_on({ set = true }, "action_clock_status"))
+ entry({"admin", "system", "system"}, view("system/system"), _("System"), 1)
entry({"admin", "system", "admin"}, firstchild(), _("Administration"), 2)
- entry({"admin", "system", "admin", "password"}, template("admin_system/password"), _("Router Password"), 1)
- entry({"admin", "system", "admin", "password", "json"}, post("action_password"))
+ entry({"admin", "system", "admin", "password"}, view("system/password"), _("Router Password"), 1)
if fs.access("/etc/config/dropbear") then
- entry({"admin", "system", "admin", "dropbear"}, cbi("admin_system/dropbear"), _("SSH Access"), 2)
- entry({"admin", "system", "admin", "sshkeys"}, template("admin_system/sshkeys"), _("SSH-Keys"), 3)
- entry({"admin", "system", "admin", "sshkeys", "json"}, post_on({ keys = true }, "action_sshkeys"))
+ entry({"admin", "system", "admin", "dropbear"}, view("system/dropbear"), _("SSH Access"), 2)
+ entry({"admin", "system", "admin", "sshkeys"}, view("system/sshkeys"), _("SSH-Keys"), 3)
end
- entry({"admin", "system", "startup"}, form("admin_system/startup"), _("Startup"), 45)
- entry({"admin", "system", "crontab"}, form("admin_system/crontab"), _("Scheduled Tasks"), 46)
+ entry({"admin", "system", "startup"}, view("system/startup"), _("Startup"), 45)
+ entry({"admin", "system", "crontab"}, view("system/crontab"), _("Scheduled Tasks"), 46)
if fs.access("/sbin/block") and fs.access("/etc/config/fstab") then
- entry({"admin", "system", "fstab"}, cbi("admin_system/fstab"), _("Mount Points"), 50)
- entry({"admin", "system", "fstab", "mount"}, cbi("admin_system/fstab/mount"), nil).leaf = true
- entry({"admin", "system", "fstab", "swap"}, cbi("admin_system/fstab/swap"), nil).leaf = true
+ entry({"admin", "system", "mounts"}, view("system/mounts"), _("Mount Points"), 50)
end
local nodes, number = fs.glob("/sys/class/leds/*")
if number > 0 then
- entry({"admin", "system", "leds"}, cbi("admin_system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60)
+ entry({"admin", "system", "leds"}, view("system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60)
end
entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70)
entry({"admin", "system", "reboot", "call"}, post("action_reboot"))
end
-function action_clock_status()
- local set = tonumber(luci.http.formvalue("set"))
- if set ~= nil and set > 0 then
- local date = os.date("*t", set)
- if date then
- luci.sys.call("date -s '%04d-%02d-%02d %02d:%02d:%02d'" %{
- date.year, date.month, date.day, date.hour, date.min, date.sec
- })
- luci.sys.call("/etc/init.d/sysfixtime restart")
- end
- end
-
- luci.http.prepare_content("application/json")
- luci.http.write_json({ timestring = os.date("%c") })
-end
-
local function image_supported(image)
return (os.execute("sysupgrade -T %q >/dev/null" % image) == 0)
end
http.redirect(luci.dispatcher.build_url('admin/system/flashops'))
end
-function action_password()
- local password = luci.http.formvalue("password")
- if not password then
- luci.http.status(400, "Bad Request")
- return
- end
-
- luci.http.prepare_content("application/json")
- luci.http.write_json({ code = luci.sys.user.setpasswd("root", password) })
-end
-
-function action_sshkeys()
- local keys = luci.http.formvalue("keys")
- if keys then
- keys = luci.jsonc.parse(keys)
- if not keys or type(keys) ~= "table" then
- luci.http.status(400, "Bad Request")
- return
- end
-
- local fd, err = io.open("/etc/dropbear/authorized_keys", "w")
- if not fd then
- luci.http.status(503, err)
- return
- end
-
- local _, k
- for _, k in ipairs(keys) do
- if type(k) == "string" and k:match("^%w+%-") then
- fd:write(k)
- fd:write("\n")
- end
- end
-
- fd:close()
- end
-
- local fd, err = io.open("/etc/dropbear/authorized_keys", "r")
- if not fd then
- luci.http.status(503, err)
- return
- end
-
- local rv = {}
- while true do
- local ln = fd:read("*l")
- if not ln then
- break
- elseif ln:match("^[%w%-]+%s+[A-Za-z0-9+/=]+$") or
- ln:match("^[%w%-]+%s+[A-Za-z0-9+/=]+%s")
- then
- rv[#rv+1] = ln
- end
- end
-
- fd:close()
-
- luci.http.prepare_content("application/json")
- luci.http.write_json(rv)
-end
-
function action_reboot()
luci.sys.reboot()
end