summaryrefslogtreecommitdiffstats
path: root/fetchmail-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'fetchmail-model.lua')
-rw-r--r--fetchmail-model.lua43
1 files changed, 37 insertions, 6 deletions
diff --git a/fetchmail-model.lua b/fetchmail-model.lua
index 6e446fd..6556209 100644
--- a/fetchmail-model.lua
+++ b/fetchmail-model.lua
@@ -12,11 +12,17 @@ local configfile = "/root/.fetchmailrc"
local config = {}
local function get_version()
- local cmd = "/usr/bin/fetchmail --version 2>/dev/null"
+ local cmd_output_result, cmd_output_error
+ local cmd = "/sbin/apk_version -vs " .. processname .." 2>/dev/null"
local f = io.popen( cmd )
- local cmd_output_result = f:read("*l")
+ local cmdresult = f:read("*l")
+ if (cmdresult) and (#cmdresult > 0) then
+ cmd_output_result = string.match(cmdresult,"^%S*") or "Unknown"
+ else
+ cmd_output_error = "Program not installed"
+ end
f:close()
- return cmd_output_result or "Not installed"
+ return cmd_output_result,cmd_output_error
end
local function getloglevels()
@@ -181,10 +187,24 @@ pool <host> protocol etrn smtpdomain <mydomain>
return mailboxes,configcontent_postmaster,configcontent_etrn
end
+
+local function autostarts()
+ local cmd_output_result, cmd_output_error
+ local cmd = "/sbin/rc_status | egrep '^S' | egrep '" .. processname .."' 2>/dev/null"
+ local f = io.popen( cmd )
+ local cmdresult = f:read("*a")
+ if (cmdresult) and (#cmdresult > 0) then
+ cmd_output_result = "Process will autostart at next boot (at sequence '" .. string.match(cmdresult,"^%a+(%d%d)") .. "')"
+ else
+ cmd_output_error = "Not programmed to autostart"
+ end
+ f:close()
+ return cmd_output_result,cmd_output_error
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
--- action should be a CFE
function startstop_service ( self, action )
local cmd = action.value
local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, cmd)
@@ -192,25 +212,36 @@ function startstop_service ( self, action )
action.errtxt=cmderror
-- Reporting back (true|false, the original acition)
return cmdresult,action
-
end
function getstatus()
local opts = getconfig()
local status = {}
+
+ local value, errtxt = get_version()
status.version = cfe({ name = "version",
label="Program version",
- value=get_version(),
+ value=value,
+ errtxt=errtxt,
})
+
status.status = cfe({ name="status",
label="Program status",
value=procps.pidof(processname),
})
+
status.configfile = cfe({ name="configfile",
label="Config file",
value=configfile,
})
+ local autostart_sequense, autostart_errtxt = autostarts()
+ status.autostart = cfe({ name="autostart",
+ label="Autostart sequence",
+ value=autostart_sequense,
+ errtxt=autostart_errtxt,
+ })
+
--[[
if (opts["remotelogging"]) and not ((opts["remotelogging"]["value"] ~= "") and not (opts["localandnetworklog"]["value"])) then
status.logfile = cfe({ name="logfile",