diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-04-08 15:13:38 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-04-08 15:13:38 +0000 |
commit | be8a05d0e4ae337d2cee99c3197f6ef5bf5c5779 (patch) | |
tree | 83c5dd5a0649678a412bdbd82a394d5b2ec1342b /shorewall-model.lua | |
parent | f25fd756ddf5a1c7ac94d8eb2a665d828e82d322 (diff) | |
download | acf-shorewall-be8a05d0e4ae337d2cee99c3197f6ef5bf5c5779.tar.bz2 acf-shorewall-be8a05d0e4ae337d2cee99c3197f6ef5bf5c5779.tar.xz |
Cleaning up code.
git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@961 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'shorewall-model.lua')
-rw-r--r-- | shorewall-model.lua | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/shorewall-model.lua b/shorewall-model.lua index b12533d..7dee572 100644 --- a/shorewall-model.lua +++ b/shorewall-model.lua @@ -1,18 +1,24 @@ module(..., package.seeall) +-- Load libraries require("fs") require("procps") require("getopts") require("format") require("daemoncontrol") require("validator") +require("processinfo") +-- Set variables local configfile = "/etc/shorewall/shorewall.conf" local processname = "shorewall" +local packagename = "shorewall" local baseurl = "/etc/shorewall/" - local config = {} +-- ################################################################################ +-- LOCAL FUNCTIONS + local function getloglevels() local loglevels = {} for i=1,8 do @@ -106,14 +112,7 @@ local function addremove_config( addremove, file, value, orgvalue ) else return false, cfe({ name="model:addremove_config()", - errtxt="Record was not deleted!" .. -"<BR>orgvalue:" .. tostring(orgvalue) .. -"<BR>modifyrow:" .. tostring(modifyrow) .. -"<BR>orgrecordtable:" .. table.concat(orgrecordtable, ";") .. -"<BR>file:" .. tostring(file) .. -"<BR>filecontentarray:" .. table.concat(filecontentarray, ";") .. -"" - , + errtxt="Record was not deleted!", }) end @@ -169,14 +168,7 @@ local function addremove_config( addremove, file, value, orgvalue ) else return false, cfe({ name="model:addremove_config()", - errtxt="Record was not modified!".. -"<BR>orgvalue:" .. tostring(orgvalue) .. -"<BR>modifyrow:" .. tostring(modifyrow) .. -"<BR>orgrecordtable:" .. table.concat(orgrecordtable, ";") .. -"<BR>file:" .. tostring(file) .. -"<BR>filecontentarray:" .. table.concat(filecontentarray, ";") .. -"" -, + errtxt="Record was not modified!", }) end @@ -195,19 +187,6 @@ local function addremove_config( addremove, file, value, orgvalue ) 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 @@ -276,21 +255,26 @@ end function getstatus() local status = {} - local programversion,programstatus,programstate = getdetails() + + local value, errtxt = processinfo.package_version(packagename) status.version = cfe({ name = "version", label="Program version", - value=programversion, + value=value, + errtxt=errtxt, }) + + local programversion,programstatus,programstate = getdetails() status.status = cfe({ name="status", label="Program status", value=programstatus, }) + status.state = cfe({ name="state", label="Program reports", value=programstate, }) - local autostart_sequense, autostart_errtxt = autostarts() + local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname) status.autostart = cfe({ name="autostart", label="Autostart sequence", value=autostart_sequense, |