From 26305a715065027c922b1d665f270179076ac94e Mon Sep 17 00:00:00 2001 From: Nils Schneider <nils@nilsschneider.net> 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 a39fc73ad..3b04b37ce 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 f341b7797..ff248bfae 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 cd057248c..000000000 --- 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 <steven@midlink.org> - -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 5658ce9fd..ebbba3a31 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 000000000..5fe211b81 --- /dev/null +++ b/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/expertmode.htm @@ -0,0 +1,57 @@ +<%- if self.message then %> + <p class="message success"><%=self.message%></p> +<%- end %> +<%- if self.errmessage then %> + <p class="message error"><%=self.errmessage%></p> +<%- end %> +<% if not self.embedded then %> +<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>"> + <div> + <script type="text/javascript" src="<%=resource%>/cbi.js"></script> + <input type="hidden" name="cbi.submit" value="1" /> + </div> +<% end %> + <div class="cbi-map" id="cbi-<%=self.config%>"> + <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %> + <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %> + <% self:render_children() %> + <br /> + </div> +<% if not self.embedded then %> + <div class="cbi-page-actions"> +<%- + if type(self.hidden) == "table" then + for k, v in pairs(self.hidden) do +-%> + <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" /> +<%- + end + end +%> +<% if redirect then %> + <div style="float:left"> + <input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" /> + </div> +<% end %> +<%- if self.flow and self.flow.skip then %> + <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" /> +<% end %> +<%- if self.submit ~= false then %> + <input class="cbi-button cbi-button-save" type="submit" name="cbi.apply" value=" + <%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%> + " /> +<% end %> +<%- if self.reset ~= false then %> + <input class="cbi-button cbi-button-reset" type="reset" value=" + <%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%> + " /> +<% end %> +<%- if self.cancel ~= false and self.on_cancel then %> + <input class="cbi-button cbi-button-reset" type="submit" name="cbi.cancel" value=" + <%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%> + " /> +<% end %> + <script type="text/javascript">cbi_d_update();</script> + </div> +</form> +<% 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 c789bb88b..000000000 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/index.htm +++ /dev/null @@ -1,5 +0,0 @@ -<h2><a id="content" name="content">Hallo!</a></h2> -<p>Dies ist der Experten-Modus deines Freifunkknotens.</p> -<p>Hier kannst du weitere Einstellungen vornehmen, Firmware Upates - einspielen und auch vieles kaputt machen.</p> -<p>Sei bitte vorsichtig!</p> -- GitLab