gluon-luci-admin: add an info page

This commit is contained in:
Matthias Schiffer 2014-07-20 00:06:22 +02:00 committed by Nils Schneider
parent 71c9bb815f
commit 12144126fe
3 changed files with 48 additions and 25 deletions

View File

@ -17,10 +17,9 @@ module("luci.controller.admin.index", package.seeall)
function index() function index()
local uci_state = luci.model.uci.cursor_state() local uci_state = luci.model.uci.cursor_state()
local setup_mode = uci_state:get_first("gluon-setup-mode", "setup_mode", "running", "0") == "1"
-- Disable gluon-luci-admin when setup mode is not enabled -- Disable gluon-luci-admin when setup mode is not enabled
if not setup_mode then if uci_state:get_first('gluon-setup-mode', 'setup_mode', 'running', '0') ~= '1' then
return return
end end
@ -32,29 +31,9 @@ function index()
local page = entry({"admin"}, alias("admin", "index"), "Expert Mode", 10) local page = entry({"admin"}, alias("admin", "index"), "Expert Mode", 10)
page.sysauth = "root" page.sysauth = "root"
if setup_mode then
-- force root to be logged in when running in setup_mode
page.sysauth_authenticator = function() return "root" end page.sysauth_authenticator = function() return "root" end
else
page.sysauth_authenticator = "htmlauth"
end
page.index = true page.index = true
entry({"admin", "index"}, cbi("admin/remote"), "Remotezugriff", 1).ignoreindex = true entry({"admin", "index"}, cbi("admin/info"), _("Info"), 1).ignoreindex = true
entry({"admin", "remote"}, cbi("admin/remote"), _("Remotezugriff"), 10)
if not setup_mode then
entry({"admin", "logout"}, call("action_logout"), "Logout")
end
end
function action_logout()
local dsp = require "luci.dispatcher"
local sauth = require "luci.sauth"
if dsp.context.authsession then
sauth.kill(dsp.context.authsession)
dsp.context.urltoken.stok = nil
end
luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url())
luci.http.redirect(luci.dispatcher.build_url())
end end

View File

@ -0,0 +1,4 @@
local t = Template('admin/info')
t.pageaction = false
return t

View File

@ -0,0 +1,40 @@
<%-
local fs = require 'luci.fs'
local uci = require('luci.model.uci').cursor()
local util = require 'luci.util'
local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform'
local keys = {
hostname = 'Hostname',
primary_mac = 'MAC-Adresse',
model = 'Hardware-Modell',
version = 'Gluon-Version',
release = 'Firmware-Release',
site = 'Site',
pubkey = 'Öffentlicher VPN-Schlüssel',
}
local values = {
hostname = uci:get_first('system', 'system', 'hostname'),
primary_mac = sysconfig.primary_mac,
model = platform.get_model(),
version = util.trim(fs.readfile('/lib/gluon/gluon-version')),
release = util.trim(fs.readfile('/lib/gluon/release')),
site = site.site_name,
}
local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn'))
if pubkey ~= '' then
values.pubkey = pubkey
end
-%>
<h2>Info</h2>
<% for _, key in ipairs({'hostname', 'primary_mac', 'model', 'version', 'release', 'site', 'pubkey'}) do %>
<div class="cbi-value">
<div class="cbi-value-title"><%=keys[key]%></div><div class="cbi-value-field"><%=values[key] or 'n/a'%></div>
</div>
<% end %>