diff options
| author | Mika Havela <mika.havela@gmail.com> | 2008-04-02 08:49:15 +0000 | 
|---|---|---|
| committer | Mika Havela <mika.havela@gmail.com> | 2008-04-02 08:49:15 +0000 | 
| commit | 913b0dbe7a980d2c72a052e397f082050f072836 (patch) | |
| tree | b9ea1922839f8e5e7a539f3fd541c45b76c47f5d /fetchmail-model.lua | |
| parent | 878bdd0f35a7aa5eb044e57341e2bd6d2c7312e8 (diff) | |
| download | acf-fetchmail-913b0dbe7a980d2c72a052e397f082050f072836.tar.bz2 acf-fetchmail-913b0dbe7a980d2c72a052e397f082050f072836.tar.xz | |
Show autostart sequence.v0.1.0
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
Diffstat (limited to 'fetchmail-model.lua')
| -rw-r--r-- | fetchmail-model.lua | 43 | 
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", | 
