summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2012-03-07 11:22:25 +0000
committerMika Havela <mika.havela@gmail.com>2012-03-07 11:22:25 +0000
commit00e3c8dc0c4c3f22b0b9173a215f276dcc659bfc (patch)
tree5f109d211184580b2b67c651727189fc5c1f69ec
downloadacf-vlc-daemon-00e3c8dc0c4c3f22b0b9173a215f276dcc659bfc.tar.bz2
acf-vlc-daemon-00e3c8dc0c4c3f22b0b9173a215f276dcc659bfc.tar.xz
acf-vlc-daemon. New acf to control vlc-sessions.
It supports multiple vlc-sessions: 1) ln -s /etc/init.d/vlc /etc/init.d/vlc-newsession 2) cp /etc/conf.d/vlc /etc/conf.d/vlc-newsession 3) vi /etc/conf.d/vlc-newsession 4) ln -s /usr/share/acf/app/vlc /usr/share/acf/app/vlc-newsession 5) Logged on as root on ACF, use 'User management' to give selected users permissions to use acf-vlc-newsession
-rw-r--r--vlc-controller.lua28
-rw-r--r--vlc-expert-html.lsp12
-rw-r--r--vlc-logfile-html.lsp50
-rw-r--r--vlc-model.lua71
-rw-r--r--vlc-startstop-html.lsp22
-rw-r--r--vlc-status-html.lsp36
-rw-r--r--vlc.menu5
-rw-r--r--vlc.roles2
8 files changed, 226 insertions, 0 deletions
diff --git a/vlc-controller.lua b/vlc-controller.lua
new file mode 100644
index 0000000..8199735
--- /dev/null
+++ b/vlc-controller.lua
@@ -0,0 +1,28 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("controllerfunctions")
+
+mvc = {}
+mvc.on_load = function(self, parent)
+ self.model.set_processname(string.match(self.conf.prefix, "[^/]+"))
+end
+
+default_action = "status"
+
+function status(self)
+ return self.model.getstatus()
+end
+
+function startstop(self)
+ return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.clientdata)
+end
+
+function expert(self)
+ return controllerfunctions.handle_form(self, self.model.getconfigfile, self.model.setconfigfile, self.clientdata, "Save", "Edit Config File", "Configuration File Set")
+end
+
+function logfile(self)
+ return self.model.get_filedetails(self.clientdata.name or "", self.clientdata.grep)
+
+end
diff --git a/vlc-expert-html.lsp b/vlc-expert-html.lsp
new file mode 100644
index 0000000..5db9173
--- /dev/null
+++ b/vlc-expert-html.lsp
@@ -0,0 +1,12 @@
+<% local form, viewlibrary, page_info, session = ... %>
+<% require("viewfunctions") %>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("status")
+end %>
+
+<%
+local pattern = string.gsub(page_info.prefix..page_info.controller, "[%(%)%.%%%+%-%*%?%[%]%^%$]", "%%%1")
+local func = haserl.loadfile(page_info.viewfile:gsub(pattern..".*$", "/") .. "filedetails-html.lsp")
+func(form, viewlibrary, page_info, session)
+%>
diff --git a/vlc-logfile-html.lsp b/vlc-logfile-html.lsp
new file mode 100644
index 0000000..ab79f8a
--- /dev/null
+++ b/vlc-logfile-html.lsp
@@ -0,0 +1,50 @@
+<% local form, viewlibrary, page_info = ... %>
+<% require("viewfunctions") %>
+
+<H1>Logfile</H1>
+<H2>File Details</H2>
+<DL>
+<%
+displayitem(form.value.filename)
+displayitem(form.value.filesize)
+displayitem(form.value.mtime)
+--if form.value.grep.value ~= "" then
+-- displayitem(form.value.grep)
+--end
+%>
+</DL>
+
+<H2>File Content</H2>
+
+<DL>
+<% 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="<%= html.html_escape(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(html.html_escape(form.value.filecontent.errtxt), "\n", "<BR>") %></P><% end %>
+<% if form.value.filecontent.descr then %><P CLASS='descr'><%= string.gsub(html.html_escape(form.value.filecontent.descr), "\n", "<BR>") %></P><% end %>
+
+<% if form.type == "form" then %>
+<% displayformend(form) %>
+<% end %>
+</form>
+</DL>
+
+<%
+--[[
+print("<H2>Debug info for page '"..tostring(page_info.action).."'</H2>")
+--form["value"]["filecontent"]["value"]=nil
+print("<H3>form</H3>")
+print(cfe_unpack(form))
+print("<H3>viewlibrary</H3>")
+print(cfe_unpack(viewlibrary))
+print("<H3>page_info</H3>")
+print(cfe_unpack(page_info))
+print("<H3>session</H3>")
+print(cfe_unpack(session))
+--]]
+%>
diff --git a/vlc-model.lua b/vlc-model.lua
new file mode 100644
index 0000000..d2fe0cb
--- /dev/null
+++ b/vlc-model.lua
@@ -0,0 +1,71 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("fs")
+
+-- ################################################################################
+-- SET VARIABLES
+local packagename="vlc-daemon"
+local packagename="vlc"
+local processname="vlc"
+local configfile = "/etc/conf.d/"..tostring(processname)
+local logfile = "/var/log/vlc/vlc.log"
+
+function set_processname(p)
+ processname = p
+ configfile = "/etc/conf.d/"..tostring(processname)
+end
+
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function startstop_service(action)
+ return modelfunctions.startstop_service(processname, action)
+end
+
+function getstatus()
+ return modelfunctions.getstatus(processname, packagename, tostring(processname).." Status")
+end
+
+function getconfigfile()
+ -- FIXME Validate
+ return modelfunctions.getfiledetails(configfile)
+end
+
+get_filedetails = function (path)
+ local path=logfile
+ for line in string.gmatch(fs.read_file(configfile), "(.-)\n") do
+ path=string.match(line,"^VLC_OPTS.*%-%-logfile%s+(%S+)") or path
+ end
+
+
+ local file = path
+ local st = fs.stat(path)
+ if st and st.type then
+ while st.type == "link" do
+ st = fs.stat(posix.readlink(st.path))
+ end
+ file = st.path
+ end
+
+ local filedetails = modelfunctions.getfiledetails(file)
+ filedetails.value.filename.value = path
+
+ return filedetails
+end
+
+function setconfigfile(filedetails)
+ -- FIXME Validate
+ return modelfunctions.setfiledetails(filedetails, {configfile})
+end
+
+function getleases()
+ return modelfunctions.getfiledetails(leasefile)
+end
+
diff --git a/vlc-startstop-html.lsp b/vlc-startstop-html.lsp
new file mode 100644
index 0000000..c98208b
--- /dev/null
+++ b/vlc-startstop-html.lsp
@@ -0,0 +1,22 @@
+<% local data, viewlibrary, page_info = ... %>
+
+<H1>Management</H1>
+
+<% if data.value.result then %>
+<H2>Previous action result</H2>
+<% if data.value.result.value ~= "" then %>
+<P CLASS='descr'><%= string.gsub(html.html_escape(data.value.result.value), "\n", "<BR>") %></P>
+<% end if data.value.result.errtxt then %>
+<P CLASS='error'><%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "<BR>") %></P>
+<% end end %>
+
+<DL>
+<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>" method="POST">
+<DT>Program control-panel</DT>
+<DD>
+<% for i,act in ipairs(data.value.actions.value) do %>
+ <input class="submit" type="submit" name="action" value="<%= act %>">
+<% end %>
+</DD>
+</form>
+</DL>
diff --git a/vlc-status-html.lsp b/vlc-status-html.lsp
new file mode 100644
index 0000000..5518c04
--- /dev/null
+++ b/vlc-status-html.lsp
@@ -0,0 +1,36 @@
+<% local data, viewlibrary, page_info, session = ...
+require("viewfunctions")
+%>
+
+<% displaycommandresults({"install","edit"}, session) %>
+<% displaycommandresults({"startstop"}, session) %>
+
+<H1>System Info</H1>
+<DL>
+<%
+displayitem(data.value.status)
+
+displayitem(data.value.version)
+if data.value.version and data.value.version.errtxt and viewlibrary.check_permission("apk-tools/apk/install") then
+%>
+ <DT>Install package</DT>
+ <DD><form action="<%= html.html_escape(page_info.script .. "/apk-tools/apk/install") %>" method="POST">
+ <input type='hidden' name='package' value='<%= html.html_escape(data.value.version.name) %>'>
+ <input class='submit' type='submit' value='Install'></form></DD>
+<%
+end
+
+displayitem(data.value.autostart)
+if not (data.value.version and data.value.version.errtxt) and data.value.autostart and data.value.autostart.errtxt and viewlibrary.check_permission("alpine-baselayout/rc/edit") then
+%>
+ <DT>Enable autostart</DT>
+ <DD><form action="<%= html.html_escape(page_info.script .. "/alpine-baselayout/rc/edit") %>" method="POST">
+ <input type='hidden' name='servicename' value='<%= html.html_escape(data.value.autostart.name) %>'>
+ <input type='hidden' name='redir' value='<%= html.html_escape(page_info.orig_action) %>'>
+ <input class='submit' type='submit' value='Enable'></form></DD>
+<% end %>
+</DL>
+
+<% if viewlibrary and viewlibrary.dispatch_component and viewlibrary.check_permission("startstop") then
+ viewlibrary.dispatch_component("startstop")
+end %>
diff --git a/vlc.menu b/vlc.menu
new file mode 100644
index 0000000..57c29bf
--- /dev/null
+++ b/vlc.menu
@@ -0,0 +1,5 @@
+#CAT GROUP/DESC TAB ACTION
+Applications 10vlc Status status
+Applications 90vlc Expert expert
+Applications 95vlc Logfile logfile
+
diff --git a/vlc.roles b/vlc.roles
new file mode 100644
index 0000000..44ed467
--- /dev/null
+++ b/vlc.roles
@@ -0,0 +1,2 @@
+USER=vlc:status
+ADMIN=vlc:status,vlc:expert,vlc:startstop,vlc:logfile