summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--alpine-baselayout.roles4
-rw-r--r--rc-controller.lua4
-rw-r--r--rc-model.lua28
-rw-r--r--rc-status-html.lsp19
4 files changed, 48 insertions, 7 deletions
diff --git a/alpine-baselayout.roles b/alpine-baselayout.roles
index 257d8d8..c17fa71 100644
--- a/alpine-baselayout.roles
+++ b/alpine-baselayout.roles
@@ -1,5 +1,5 @@
GUEST=hostname:read
-USER=cron:status,cron:startstop,health:system,health:storage,health:proc,health:network,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,modules:status,syslog:status,syslog:loginfo,syslog:startstop,rc:status
+USER=cron:status,cron:startstop,health:system,health:storage,health:proc,health:network,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,modules:status,syslog:status,syslog:loginfo,syslog:startstop,rc:status,rc:startstop
EDITOR=cron:listjobs,hostname:edit,interfaces:delete,interfaces:create,interfaces:update,interfaces:ifup,interfaces:ifdown,logfiles:delete,syslog:config,rc:edit
EXPERT=cron:editjob,cron:deletejob,cron:movejob,cron:createjob,cron:expert,syslog:expert,interfaces:editintfile,modules:edit,modules:reload
-ADMIN=cron:status,cron:startstop,cron:listjobs,cron:editjob,cron:deletejob,cron:movejob,cron:createjob,cron:expert,hostname:read,health:system,health:storage,health:proc,health:network,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,modules:status,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
+ADMIN=cron:status,cron:startstop,cron:listjobs,cron:editjob,cron:deletejob,cron:movejob,cron:createjob,cron:expert,hostname:read,health:system,health:storage,health:proc,health:network,health:networkstats,interfaces:status,interfaces:read,interfaces:restart,logfiles:status,logfiles:view,logfiles:download,logfiles:tail,modules:status,syslog:status,syslog:loginfo,syslog:startstop,rc:status,rc:startstop,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/rc-controller.lua b/rc-controller.lua
index 69fd183..ba235b6 100644
--- a/rc-controller.lua
+++ b/rc-controller.lua
@@ -13,3 +13,7 @@ edit = function(self)
function() return self.model.read_runlevels(self.clientdata.servicename) end,
self.model.update_runlevels, self.clientdata, "Save", "Edit Service Runlevels")
end
+
+startstop = function(self)
+ return self:redirect_to_referrer(self.model.handle_startstop(self.clientdata.servicename, self.clientdata.action))
+end
diff --git a/rc-model.lua b/rc-model.lua
index c213e1f..215d02d 100644
--- a/rc-model.lua
+++ b/rc-model.lua
@@ -17,7 +17,16 @@ table.sort(runlevels)
local config
status = function()
- config = config or processinfo.read_initrunlevels()
+ if not config then
+ config = processinfo.read_initrunlevels()
+ for i,c in pairs(config) do
+ c.actions, c.description = processinfo.daemon_actions(c.servicename)
+ c.status = processinfo.daemoncontrol(c.servicename, "status")
+ if c.status then
+ c.status = string.match(c.status, "status: (.*)")
+ end
+ end
+ end
return cfe({ type="structure", value=config, label="Init Runlevels" })
end
@@ -73,3 +82,20 @@ update_runlevels = function(service)
return service
end
+
+handle_startstop = function(servicename, action)
+ local result = ""
+ local errtxt
+ local actions,errtxt = processinfo.daemon_actions(servicename)
+ if actions then
+ errtxt = nil
+ local reverseactions = {}
+ for i,act in ipairs(actions) do reverseactions[string.lower(act)] = i end
+ if reverseactions[string.lower(action)] then
+ result, errtxt = processinfo.daemoncontrol(servicename, action)
+ else
+ errtxt = "Unknown command!"
+ end
+ end
+ return cfe({ label="Start/Stop result", value=result, errtxt=errtxt })
+end
diff --git a/rc-status-html.lsp b/rc-status-html.lsp
index 446c826..b04913a 100644
--- a/rc-status-html.lsp
+++ b/rc-status-html.lsp
@@ -1,16 +1,19 @@
<% local view, viewlibrary, page_info, session = ... %>
<% require("viewfunctions") %>
-<% displaycommandresults({"edit"}, session) %>
+<% displaycommandresults({"edit", "startstop"}, session) %>
<H1><%= html.html_escape(view.label) %></H1>
<DL>
<TABLE>
<TR>
<% if viewlibrary.check_permission("edit") then %>
-<TD class='header'>Action</TD>
+<th>Action</th>
<% end %>
-<TD class='header'>Service Name</TD><TD class='header'>Runlevels</TD>
+<th>Service Name</th>
+<th>Status</th>
+<th>Runlevels</th>
+<th>Description</th>
</TR>
<%
for i,item in ipairs(view.value) do %>
@@ -18,7 +21,15 @@ for i,item in ipairs(view.value) do %>
<% if viewlibrary.check_permission("edit") then %>
<TD><%= html.link{value="edit?servicename="..item.servicename.."&redir="..page_info.orig_action, label="Edit " } %>
<% end %>
- <TD><%= html.html_escape(item.servicename) %></TD><TD><%= html.html_escape(table.concat(item.runlevels, ", ")) %>&nbsp;</TD>
+ <% if viewlibrary.check_permission("startstop") and item.actions then
+ for i,a in ipairs(item.actions) do
+ print(html.link{value="startstop?servicename="..item.servicename.."&action="..a, label=a:gsub("^%l", string.upper).." " })
+ end
+ end %>
+ <TD><%= html.html_escape(item.servicename) %></TD>
+ <TD><%= html.html_escape(item.status) %></TD>
+ <TD><%= html.html_escape(table.concat(item.runlevels, ", ")) %>&nbsp;</TD>
+ <TD><%= html.html_escape(item.description) %></TD>
</TR>
<% end %>
</TABLE>