From ec1cd35aa4e62a931a8f92173810e61a5c51798c Mon Sep 17 00:00:00 2001 From: ttrask Date: Fri, 27 Feb 2009 15:15:04 +0000 Subject: Fixed postfix bug with enabled status. git-svn-id: svn://svn.alpinelinux.org/acf/postfix/trunk@1719 ab2d0c66-481e-0410-8bed-d214d4d58bed --- postfix-model.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'postfix-model.lua') 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() -- cgit v1.2.3