diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-08-12 15:53:20 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-08-12 15:53:20 +0000 |
commit | 7ccca7213d3137b0764ef02165c44f4bd3373f45 (patch) | |
tree | 72f8ec88e7e5242abc5196043f21552d07e66f0f /dansguardian-model.lua | |
parent | a538c188976821b77959aadbcfc7ce0639f0aa24 (diff) | |
download | acf-dansguardian-7ccca7213d3137b0764ef02165c44f4bd3373f45.tar.bz2 acf-dansguardian-7ccca7213d3137b0764ef02165c44f4bd3373f45.tar.xz |
Modified dansguardian to use new status, startstop, and expert (replaced plain) actions.
git-svn-id: svn://svn.alpinelinux.org/acf/dansguardian/trunk@1380 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'dansguardian-model.lua')
-rw-r--r-- | dansguardian-model.lua | 81 |
1 files changed, 9 insertions, 72 deletions
diff --git a/dansguardian-model.lua b/dansguardian-model.lua index 3159644..7fb76a1 100644 --- a/dansguardian-model.lua +++ b/dansguardian-model.lua @@ -2,6 +2,7 @@ module (..., package.seeall) -- Load libraries +require("modelfunctions") require "posix" require "format" require("processinfo") @@ -46,48 +47,12 @@ local categoryfilecontent = { -- ################################################################################ -- PUBLIC FUNCTIONS -get_autostart = function() - local autostart_sequense, autostart_errtxt = processinfo.process_botsequence(processname) - local retval = cfe({ name="autostart", - label="Autostart sequence", - value=autostart_sequense, - errtxt=autostart_errtxt, - }) - return retval -end - get_status = function() - local t = procps.pidof(procname) - local stats - if (t) and (#t > 0) then - stats = "Enabled" - else - stats = "Disabled" - end - local retval = cfe({ name="status", - label="Program status", - value=stats, - }) - return retval + return modelfunctions.getstatus(processname, packagename, "Dans Guardian Status") end -service_control = function( cmd ) - local action = {value=cmd} - local cmdresult,cmdmessage,cmderror,cmdaction = daemoncontrol.daemoncontrol(processname, cmd) - action.descr=cmdmessage - action.errtxt=cmderror - return cmdresult,action -end - - -get_dansguardian_version = function() - local value, errtxt = processinfo.package_version(packagename) - local retval = cfe({ name = "version", - label="Program version", - value=value, - errtxt=errtxt, - }) - return retval +startstop_service = function( action ) + return modelfunctions.startstop_service(processname, action) end get_general_config = function() @@ -146,24 +111,8 @@ get_general_config = function() return retval, error end -get_plain_config = function() - - local retval = "" - local error = "" - - local fptr = io.open( dansguardiancfg, "r" ) - if fptr ~= nil then - retval = fptr:read( "*a" ) - fptr:close() - if retval == nil then - retval = "" - error = "Failed to read " .. dansguardiancfg .. " file!" - end - else - error = "Failed to open " .. dansguardiancfg .. " file!" - end - - return retval, error +getconfigfile = function() + return modelfunctions.getfiledetails(dansguardiancfg) end get_edit_config = function( name ) @@ -283,21 +232,9 @@ update_general_config = function( config ) return retval end -update_plain_config = function( config ) - - local retval = "" - local cfgptr = -1 - local error = "" - - cfgptr = io.open( dansguardiancfg, "wb+" ) - if cfgptr ~= nil then - cfgptr:write( config ) - cfgptr:close() - else - retval = "Failed to open " .. dansguardiancfg .. " file!" - end - - return retval +updateconfigfile = function( filedetails ) + filedetails.value.filename.value = dansguardiancfg + return modelfunctions.setfiledetails(dansguardiancfg) end get_cfg_value = function( str ) |