summaryrefslogtreecommitdiffstats
path: root/lighttpd-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lighttpd-model.lua')
-rw-r--r--lighttpd-model.lua74
1 files changed, 74 insertions, 0 deletions
diff --git a/lighttpd-model.lua b/lighttpd-model.lua
new file mode 100644
index 0000000..53c8310
--- /dev/null
+++ b/lighttpd-model.lua
@@ -0,0 +1,74 @@
+module(..., package.seeall)
+
+-- Load libraries
+require("modelfunctions")
+require("fs")
+require("format")
+
+-- Set variables
+local processname = "lighttpd"
+local packagename = "lighttpd"
+local filelist = {"/etc/lighttpd/lightpd.conf",
+"/etc/lighttpd/mod_cgi.conf"}
+
+local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+
+-- ################################################################################
+-- LOCAL FUNCTIONS
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+
+function startstop_service(action)
+ return modelfunctions.startstop_service(processname, action)
+end
+
+function getstatus()
+ return modelfunctions.getstatus(processname, packagename,
+"Lighttpd Status")
+end
+
+function getstatusdetails()
+ return cfe({ type="longtext", value="", label="Lighttpd Status
+Details" })
+end
+
+function getfilelist()
+ local listed_files = {}
+
+ for i,name in ipairs(filelist) do
+ local filedetails = fs.stat(name) or {}
+ table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} )
+ end
+
+ table.sort(listed_files, function (a,b) return (a.filename < b.filename) end )
+
+ return cfe({ type="list", value=listed_files, label="Lighttpd
+File List" })
+end
+
+function getfiledetails(filename)
+ return modelfunctions.getfiledetails(filename, filelist)
+end
+
+function updatefiledetails(filedetails)
+ return modelfunctions.setfiledetails(filedetails, filelist)
+end
+
+function getlogfile ()
+ local files = {}
+ local logfilepath = format.parse_configfile(fs.read_file(filelist[1]) or "").LogFile
+ if not logfilepath then
+ files[#files+1] = {path =
+"/var/log/lighttpd/access.log"}
+ else
+ files[#files+1] = {path=logfilepath}
+ end
+ logfilepath = format.parse_configfile(fs.read_file(filelist[2]) or "").UpdateLogFile
+ if not logfilepath then
+ files[#files+1] = {path = "/var/log/eror.log"}
+ else
+ files[#files+1] = {path=logfilepath}
+ end
+ return cfe({ value=files, label="Lighttpd logfiles" })
+end