summaryrefslogtreecommitdiffstats
path: root/shorewall-model.lua
diff options
context:
space:
mode:
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)