From 913b0dbe7a980d2c72a052e397f082050f072836 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 2 Apr 2008 08:49:15 +0000 Subject: Show autostart sequence. Disable not working config-tab. Hiding management-buttons because there exists no /etc/init.d/fetchmail script. git-svn-id: svn://svn.alpinelinux.org/acf/fetchmail/trunk@889 ab2d0c66-481e-0410-8bed-d214d4d58bed --- fetchmail-model.lua | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'fetchmail-model.lua') 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 protocol etrn smtpdomain 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", -- cgit v1.2.3