summaryrefslogtreecommitdiffstats
path: root/vlc-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'vlc-model.lua')
-rw-r--r--vlc-model.lua71
1 files changed, 71 insertions, 0 deletions
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
+