2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 module("luci.controller.mini.system", package.seeall)
19 luci.i18n.loadc("admin-core")
20 local i18n = luci.i18n.translate
22 entry({"mini", "system"}, call("action_reboot"), i18n("system"))
23 entry({"mini", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 10)
24 entry({"mini", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 20)
25 entry({"mini", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 30)
28 function action_reboot()
29 local reboot = luci.http.formvalue("reboot")
30 luci.template.render("mini/reboot", {reboot=reboot})
36 function action_upgrade()
37 require("luci.model.uci")
40 local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
41 local tmpfile = "/tmp/firmware.img"
44 luci.http.setfilehandler(
45 function(meta, chunk, eof)
47 file = io.open(tmpfile, "w")
58 local fname = luci.http.formvalue("image")
59 local keepcfg = luci.http.formvalue("keepcfg")
61 if plat and fname then
64 local files = luci.model.uci.get_all("luci", "flash_keep")
65 if files.luci and files.luci.flash_keep then
67 for k,v in pairs(files.luci.flash_keep) do
68 kpattern = kpattern .. " " .. v
72 ret = luci.sys.flash(tmpfile, kpattern)
75 luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret})
78 function action_passwd()
79 local p1 = luci.http.formvalue("pwd1")
80 local p2 = luci.http.formvalue("pwd2")
85 stat = luci.sys.user.setpasswd("root", p1)
91 luci.template.render("mini/passwd", {stat=stat})