summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--postfix-model.lua25
1 files changed, 24 insertions, 1 deletions
diff --git a/postfix-model.lua b/postfix-model.lua
index 57cdc9b..b4a0863 100644
--- a/postfix-model.lua
+++ b/postfix-model.lua
@@ -24,7 +24,30 @@ function startstop_service(action)
end
function getstatus()
- return modelfunctions.getstatus(processname, packagename, "Postfix Status")
+ local status = modelfunctions.getstatus(processname, packagename, "Postfix Status")
+
+ -- Enabled status is unique for postfix
+ -- Look for pid file stored in queue_directory .. /pid/
+ local config = format.parse_ini_file(fs.read_file(baseurl.."main.cf") or "", "")
+ if config.queue_directory then
+ local pidfiles = fs.find_files_as_array(".*\.pid", config.queue_directory.."/pid/")
+ if pidfiles and pidfiles[1] then
+ local file = pidfiles[1]
+ -- check to see if there's a matching proc directory and that it was created slightly after the pid file
+ -- this allows us to avoid the problem with proc numbers wrapping
+ local tmp = string.match(fs.read_file(file) or "", "%d+")
+ if tmp then
+ local dir = "/proc/" .. tmp
+ filetime = posix.stat(file, "ctime")
+ dirtime = posix.stat(dir, "ctime")
+ if dirtime and (tonumber(dirtime) - tonumber(filetime) < 100) then
+ status.value.status.value = "Running"
+ end
+ end
+ end
+ end
+
+ return status
end
function getstatusdetails()