diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | alpine-baselayout.roles | 4 | ||||
-rw-r--r-- | modules-controller.lua | 14 | ||||
-rw-r--r-- | modules-edit-html.lsp | 43 | ||||
-rw-r--r-- | modules-model.lua | 18 | ||||
-rw-r--r-- | modules.menu | 2 |
6 files changed, 80 insertions, 2 deletions
@@ -13,6 +13,7 @@ APP_DIST=\ skins* \ rc* \ password* \ + modules* \ EXTRA_DIST=README Makefile config.mk diff --git a/alpine-baselayout.roles b/alpine-baselayout.roles index c9b2a07..f241ca8 100644 --- a/alpine-baselayout.roles +++ b/alpine-baselayout.roles @@ -1,5 +1,5 @@ GUEST=health:system,hostname:read USER=health:storage,health:proc,health:network,health:modules,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,skins:update,skins:read,syslog:status,syslog:loginfo,syslog:startstop,rc:status EDITOR=hostname:edit,interfaces:delete,interfaces:create,interfaces:update,interfaces:ifup,interfaces:ifdown,logfiles:delete,syslog:config,rc:edit -EXPERT=syslog:expert,interfaces:editintfile -ADMIN=health:system,hostname:read,health:storage,health:proc,health:network,health:modules,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,skins:update,skins:read,syslog:status,syslog:loginfo,syslog:startstop,rc:status,hostname:edit,interfaces:delete,interfaces:create,interfaces:update,interfaces:ifup,interfaces:ifdown,logfiles:delete,syslog:config,rc:edit,syslog:expert,interfaces:editintfile,password:edit +EXPERT=syslog:expert,interfaces:editintfile,modules:edit,modules:reload +ADMIN=health:system,hostname:read,health:storage,health:proc,health:network,health:modules,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,skins:update,skins:read,syslog:status,syslog:loginfo,syslog:startstop,rc:status,hostname:edit,interfaces:delete,interfaces:create,interfaces:update,interfaces:ifup,interfaces:ifdown,logfiles:delete,syslog:config,rc:edit,syslog:expert,interfaces:editintfile,modules:edit,modules:reload,password:edit diff --git a/modules-controller.lua b/modules-controller.lua new file mode 100644 index 0000000..f1da11c --- /dev/null +++ b/modules-controller.lua @@ -0,0 +1,14 @@ +-- the interfaces controller +require("controllerfunctions") + +module (..., package.seeall) + +default_action = "edit" + +edit = function(self) + return controllerfunctions.handle_form(self, self.model.read_file, self.model.write_file, self.clientdata, "Save", "Edit Modules file", "File saved") +end + +reload = function(self) + return self:redirect_to_referrer(self.model.reloadmodules()) +end diff --git a/modules-edit-html.lsp b/modules-edit-html.lsp new file mode 100644 index 0000000..75c360f --- /dev/null +++ b/modules-edit-html.lsp @@ -0,0 +1,43 @@ +<% local form, viewlibrary, page_info, session = ... %> +<% require("viewfunctions") %> + +<% displaycommandresults({"reload"}, session) %> + +<% if form.type == "form" then %> +<H1>Configuration</H1> +<H2>Expert Configuration</H2> +<% else %> +<H1>View File</H1> +<% end %> +<H3>File Details</H3> +<DL> +<% +displayitem(form.value.filename) +displayitem(form.value.filesize) +displayitem(form.value.mtime) +%> +</DL> + +<H3>File Content</H3> +<% if form.type == "form" then %> +<% form.action = page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action %> +<% displayformstart(form) %> +<input type="hidden" name="filename" value="<%= form.value.filename.value %>"> +<% end %> +<textarea name="filecontent"> +<%= html.html_escape(form.value.filecontent.value) %> +</textarea> +<% if form.value.filecontent.errtxt then %><P CLASS='error'><%= string.gsub(form.value.filecontent.errtxt, "\n", "<BR>") %></P><% end %> +<% if form.value.filecontent.descr then %><P CLASS='descr'><%= string.gsub(form.value.filecontent.descr, "\n", "<BR>") %></P><% end %> + +<% if form.type == "form" then %> +<H3>Save</H3> +<% displayformend(form) %> +<% end %> +</form> + +<H1>Reload Modules</H1> +<DL> +<DT>Reload Modules</DT> +<DD><form action="<%= page_info.script .. page_info.prefix .. page_info.controller .. "/reload" %>"><input class="submit" type="submit" value="Reload"></form></DD> +</DL> diff --git a/modules-model.lua b/modules-model.lua new file mode 100644 index 0000000..751aa3d --- /dev/null +++ b/modules-model.lua @@ -0,0 +1,18 @@ +module (..., package.seeall) + +require("modelfunctions") +require("fs") + +local configfile = "/etc/modules" + +function read_file() + return modelfunctions.getfiledetails(configfile) +end + +function write_file(filedetails) + return modelfunctions.setfiledetails(filedetails, {configfile}) +end + +function reloadmodules() + return modelfunctions.startstop_service("modutils", "start") +end diff --git a/modules.menu b/modules.menu new file mode 100644 index 0000000..4f96581 --- /dev/null +++ b/modules.menu @@ -0,0 +1,2 @@ +# Cat Group Tab Action +System 20Modules Status edit |