modules/admin-full:
[project/luci.git] / modules / admin-full / luasrc / controller / admin / status.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 module("luci.controller.admin.status", package.seeall)
15
16 function index()
17         luci.i18n.loadc("admin-core")
18         local i18n = luci.i18n.translate
19
20         entry({"admin", "status"}, template("admin_status/index"), i18n("status", "Status"), 20).index = true
21         entry({"admin", "status", "interfaces"}, template("admin_status/interfaces"), i18n("interfaces", "Interfaces"), 1)
22         entry({"admin", "status", "iptables"}, call("action_iptables"), i18n("a_s_ipt", "Firewall"), 2)
23         entry({"admin", "status", "conntrack"}, form("admin_status/conntrack"), i18n("a_n_conntrack"), 3)
24         entry({"admin", "status", "routes"}, form("admin_status/routes"), i18n("a_n_routes"), 4)
25         entry({"admin", "status", "syslog"}, call("action_syslog"), i18n("syslog", "System Log"), 5)
26         entry({"admin", "status", "dmesg"}, call("action_dmesg"), i18n("dmesg", "Kernel Log"), 6)
27
28 end
29
30 function action_syslog()
31         local syslog = luci.sys.syslog()
32         luci.template.render("admin_status/syslog", {syslog=syslog})
33 end
34
35 function action_dmesg()
36         local dmesg = luci.sys.dmesg()
37         luci.template.render("admin_status/dmesg", {dmesg=dmesg})
38 end
39
40 function action_iptables()
41         if luci.http.formvalue("zero") == "1" then
42                 luci.util.exec("iptables -Z")
43                 luci.http.redirect(
44                         luci.dispatcher.build_url("admin", "status", "iptables")
45                 )
46         elseif luci.http.formvalue("restart") == "1" then
47                 luci.util.exec("/etc/init.d/firewall restart")
48                 luci.http.redirect(
49                         luci.dispatcher.build_url("admin", "status", "iptables")
50                 )
51         else
52                 luci.template.render("admin_status/iptables")
53         end
54 end