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"}, alias("mini", "system", "index"), i18n("system"), 40)
23 entry({"mini", "system", "index"}, cbi("mini/system"), i18n("general"), 1)
24 entry({"mini", "system", "passwd"}, call("action_passwd"), i18n("a_s_changepw"), 10)
25 entry({"mini", "system", "upgrade"}, call("action_upgrade"), i18n("a_s_flash"), 90)
26 entry({"mini", "system", "reboot"}, call("action_reboot"), i18n("reboot"), 100)
29 function action_reboot()
30 local reboot = luci.http.formvalue("reboot")
31 luci.template.render("mini/reboot", {reboot=reboot})
37 function action_upgrade()
38 require("luci.model.uci")
41 local plat = luci.fs.mtime("/lib/upgrade/platform.sh")
42 local tmpfile = "/tmp/firmware.img"
45 luci.http.setfilehandler(
46 function(meta, chunk, eof)
48 file = io.open(tmpfile, "w")
59 local fname = luci.http.formvalue("image")
60 local keepcfg = luci.http.formvalue("keepcfg")
62 if plat and fname then
65 local files = luci.model.uci.get_all("luci", "flash_keep")
66 if files.luci and files.luci.flash_keep then
68 for k,v in pairs(files.luci.flash_keep) do
69 kpattern = kpattern .. " " .. v
73 ret = luci.sys.flash(tmpfile, kpattern)
76 luci.template.render("mini/upgrade", {sysupgrade=plat, ret=ret})
79 function action_passwd()
80 local p1 = luci.http.formvalue("pwd1")
81 local p2 = luci.http.formvalue("pwd2")
86 stat = luci.sys.user.setpasswd("root", p1)
92 luci.template.render("mini/passwd", {stat=stat})