summaryrefslogtreecommitdiffstats
path: root/shorewall-model.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2007-11-30 16:41:55 +0000
committerMika Havela <mika.havela@gmail.com>2007-11-30 16:41:55 +0000
commit2beb00dd81c1f2dceeef0e62cf89d2d1b1109b6a (patch)
tree01f636fa19ea255f602bdb4d622e9078f74beeb7 /shorewall-model.lua
parent3a4f180a70063a185a8eab0e1409b255f0762861 (diff)
downloadacf-shorewall-2beb00dd81c1f2dceeef0e62cf89d2d1b1109b6a.tar.bz2
acf-shorewall-2beb00dd81c1f2dceeef0e62cf89d2d1b1109b6a.tar.xz
Check and restart is now working!
git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@396 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'shorewall-model.lua')
-rw-r--r--shorewall-model.lua26
1 files changed, 22 insertions, 4 deletions
diff --git a/shorewall-model.lua b/shorewall-model.lua
index b57e354..ca26ca8 100644
--- a/shorewall-model.lua
+++ b/shorewall-model.lua
@@ -1,11 +1,11 @@
-- shorewall model methods
module (..., package.seeall)
+require("format")
local baseurl = "/etc/shorewall/"
local function file_info ( path )
require("posix")
--- modfiledetails = {}
local filedetails = posix.stat(path)
filedetails["owner"]=rawget((posix.getpasswd(filedetails["uid"])),"name")
filedetails["group"]=rawget((posix.getgroup(filedetails["gid"])),"name")
@@ -14,13 +14,31 @@ local function file_info ( path )
filedetails["longname"]=path
filedetails["name"]=basename(path)
filedetails["size"]=filedetails["size"] .. " bytes"
-
return filedetails
end
-- ################################################################################
-- PUBLIC FUNCTIONS
+function check_config ()
+ check = nil
+ check = {}
+ local f,err = io.popen("/etc/init.d/shorewall check")
+ check.result = f:read("*a")
+ f:close()
+ check["error"]=err
+ return check
+end
+
+function restart_service ()
+ -- FIXME: Read getstatus AFTER restart so the new 'restart date' is shown.
+ local status = get_status()
+ local f,err = io.popen("/etc/init.d/shorewall restart")
+ status.restart = f:read("*a")
+ f:close()
+ return status
+end
+
function get_status ()
local f,error = io.popen("/sbin/shorewall status")
local fake = f:read("*l")
@@ -42,7 +60,6 @@ function get_filelist ()
for name in posix.files(filepath) do
if not string.match(name, "^%.") and not string.match(name, "^Makefile") then
local filedetails = file_info(filepath .. name)
--- table.insert ( listed_files , {name} )
table.insert ( listed_files , {name=name, longname=filepath .. name, filedetails=filedetails} )
end
end
@@ -65,13 +82,14 @@ function get_filecontent (self, name)
end
return file_content
end
+
function update_filecontent (self, name, modifications)
path = baseurl .. name
local available_files = get_filelist()
for k,v in pairs(available_files) do
if ( available_files[k].name == name ) then
local file = io.open( path, "w+" )
- local file_result,err = file:write(modifications)
+ local file_result,err = file:write(format.dostounix(modifications))
file:close()
if (err ~= nil) then
local filedetails = file_info(path)