From 26305a715065027c922b1d665f270179076ac94e Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Wed, 19 Feb 2014 00:26:49 +0100 Subject: [PATCH] gluon-luci-admin: replace overview with ssh/pass Various changes and moving stuff around. --- .../lib/lua/luci/controller/admin/index.lua | 2 +- .../lib/lua/luci/controller/admin/upgrade.lua | 3 +- .../lib/lua/luci/model/cbi/admin/index.lua | 14 ---- .../cbi/admin/{passwd.lua => remote.lua} | 70 ++++++++++--------- .../lib/lua/luci/view/admin/expertmode.htm | 57 +++++++++++++++ .../usr/lib/lua/luci/view/admin/index.htm | 5 -- 6 files changed, 96 insertions(+), 55 deletions(-) delete mode 100644 package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/index.lua rename package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/{passwd.lua => remote.lua} (81%) create mode 100644 package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/expertmode.htm delete mode 100644 package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/index.htm diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/index.lua b/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/index.lua index a39fc73a..3b04b37c 100644 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/index.lua +++ b/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/index.lua @@ -40,7 +40,7 @@ function index() end page.index = true - entry({"admin", "index"}, form("admin/index"), "Overview", 1).ignoreindex = true + entry({"admin", "index"}, cbi("admin/remote"), "Remotezugriff", 1).ignoreindex = true if not configmode then entry({"admin", "logout"}, call("action_logout"), "Logout") diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/upgrade.lua b/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/upgrade.lua index f341b779..ff248bfa 100644 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/upgrade.lua +++ b/package/gluon-luci-admin/files/usr/lib/lua/luci/controller/admin/upgrade.lua @@ -16,8 +16,7 @@ $Id$ module("luci.controller.admin.upgrade", package.seeall) function index() - entry({"admin", "passwd"}, cbi("admin/passwd"), "Admin Password", 10) - entry({"admin", "upgrade"}, call("action_upgrade"), "Flash Firmware", 90) + entry({"admin", "upgrade"}, call("action_upgrade"), "Firmware aktualisieren", 90) end function action_upgrade() diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/index.lua b/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/index.lua deleted file mode 100644 index cd057248..00000000 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/index.lua +++ /dev/null @@ -1,14 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- -return Template("admin/index") diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/passwd.lua b/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/remote.lua similarity index 81% rename from package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/passwd.lua rename to package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/remote.lua index 5658ce9f..ebbba3a3 100644 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/passwd.lua +++ b/package/gluon-luci-admin/files/usr/lib/lua/luci/model/cbi/admin/remote.lua @@ -18,9 +18,42 @@ local fs = require "nixio.fs" local m, s, pw1, pw2 -m = Map("system", "Passwort & SSH Keys") +m = Map("system", "Remotezugriff") +m.submit = "Speichern" +m.reset = "Zurücksetzen" +m.pageaction = false +m.template = "admin/expertmode" -s = m:section(TypedSection, "Router Password", +if fs.access("/etc/config/dropbear") then + s = m:section(TypedSection, "_keys", nil, + "Here you can paste public SSH-Keys (one per line) for SSH public-key authentication.") + + s.addremove = false + s.anonymous = true + + function s.cfgsections() + return { "_keys" } + end + + local keys + + keys = s:option(TextValue, "_data", "") + keys.wrap = "off" + keys.rows = 5 + keys.rmempty = false + + function keys.cfgvalue() + return fs.readfile("/etc/dropbear/authorized_keys") or "" + end + + function keys.write(self, section, value) + if value then + fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n")) + end + end +end + +s = m:section(TypedSection, "_pass", nil, "Changes the administrator password for accessing the device") s.addremove = false @@ -45,39 +78,10 @@ function m.on_commit(map) if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then m.message = "Password successfully changed!" else - m.message = "Unknown Error, password not changed!" + m.errmessage = "Unknown Error, password not changed!" end else - m.message = "Given password confirmation did not match, password not changed!" - end - end -end - -if fs.access("/etc/config/dropbear") then - s = m:section(TypedSection, "_keys", "SSH Keys", - "Here you can paste public SSH-Keys (one per line) for SSH public-key authentication.") - - s.addremove = false - s.anonymous = true - - function s.cfgsections() - return { "_keys" } - end - - local keys - - keys = s:option(TextValue, "_data", "") - keys.wrap = "off" - keys.rows = 3 - keys.rmempty = false - - function keys.cfgvalue() - return fs.readfile("/etc/dropbear/authorized_keys") or "" - end - - function keys.write(self, section, value) - if value then - fs.writefile("/etc/dropbear/authorized_keys", value:gsub("\r\n", "\n")) + m.errmessage = "Given password confirmation did not match, password not changed!" end end end diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/expertmode.htm b/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/expertmode.htm new file mode 100644 index 00000000..5fe211b8 --- /dev/null +++ b/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/expertmode.htm @@ -0,0 +1,57 @@ +<%- if self.message then %> +

<%=self.message%>

+<%- end %> +<%- if self.errmessage then %> +

<%=self.errmessage%>

+<%- end %> +<% if not self.embedded then %> +
+
+ + +
+<% end %> +
+ <% if self.title and #self.title > 0 then %>

<%=self.title%>

<% end %> + <% if self.description and #self.description > 0 then %>
<%=self.description%>
<% end %> + <% self:render_children() %> +
+
+<% if not self.embedded then %> +
+<%- + if type(self.hidden) == "table" then + for k, v in pairs(self.hidden) do +-%> + +<%- + end + end +%> +<% if redirect then %> +
+ +
+<% end %> +<%- if self.flow and self.flow.skip then %> + +<% end %> +<%- if self.submit ~= false then %> + +<% end %> +<%- if self.reset ~= false then %> + +<% end %> +<%- if self.cancel ~= false and self.on_cancel then %> + +<% end %> + +
+
+<% end %> diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/index.htm b/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/index.htm deleted file mode 100644 index c789bb88..00000000 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/index.htm +++ /dev/null @@ -1,5 +0,0 @@ -

Hallo!

-

Dies ist der Experten-Modus deines Freifunkknotens.

-

Hier kannst du weitere Einstellungen vornehmen, Firmware Upates - einspielen und auch vieles kaputt machen.

-

Sei bitte vorsichtig!