summaryrefslogtreecommitdiffstats
path: root/shorewall-controller.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-01-15 13:44:22 +0000
committerMika Havela <mika.havela@gmail.com>2008-01-15 13:44:22 +0000
commit91f600e62d83f942e722dd18e7c42c244557a610 (patch)
treeb1374d3109b9140da0f0fecde2a8d739e091f9b3 /shorewall-controller.lua
parent880d1fbbed5e15454383dccf7c3497a8772df118 (diff)
downloadacf-shorewall-91f600e62d83f942e722dd18e7c42c244557a610.tar.bz2
acf-shorewall-91f600e62d83f942e722dd18e7c42c244557a610.tar.xz
Created a confirmation when you start/stop/restart the firewall.
git-svn-id: svn://svn.alpinelinux.org/acf/shorewall/trunk@572 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'shorewall-controller.lua')
-rw-r--r--shorewall-controller.lua81
1 files changed, 55 insertions, 26 deletions
diff --git a/shorewall-controller.lua b/shorewall-controller.lua
index 6b47dbb..8218b4d 100644
--- a/shorewall-controller.lua
+++ b/shorewall-controller.lua
@@ -17,14 +17,25 @@ mvc.on_load = function(self, parent)
end
logfile = function (self)
- return ( {logfile = self.model:get_logfile(), url = url } )
+ return ( {status = self.model:getstatus(), logfile = self.model:get_logfile(), url = url } )
end
check = function(self)
- if self.clientdata.cmd == "restart" then
- return ( {programstats = self.model:restart_service(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
+ local check = nil
+ if (self.clientdata.cmd) then
+ if self.clientdata.cmd == "stop" then
+ self.conf.action = "confirmation"
+ self.conf.type = "redir"
+ end
+ check = self.model:startstop_service(self.clientdata.cmd)
+ check = self.clientdata.cmd
+ else
+ check = self.model:check_config()
end
- return ( {check = self.model:check_config(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
+ return ( {status = self.model:getstatus(),
+ check = check,
+ previousaction = self.clientdata.cmd,
+ confirm_url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller .. "/confirmation" } )
end
@@ -34,33 +45,51 @@ status = function(self)
self.conf.type = "redir"
error (self.conf)
end
- if self.clientdata.cmd == "restart" then
- return ( {programstats = self.model:restart_service(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
- end
- return ( {status = self.model:get_status(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
+-- if self.clientdata.cmd == "restart" then
+-- return ( {programstats = self.model:restart_service(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
+-- end
+ return ( {status = self.model:getstatus(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
end
-advanced = function(self)
- return ( {filelist = self.model:get_filelist(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
+expert = function(self)
+ return ( {status = self.model:getstatus(),filelist = self.model:get_filelist(), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
end
edit = function (self)
- local filename = self.clientdata.name or ""
- local filecontent = self.clientdata.modifications or ""
- if ( filecontent ~= "") then
- local me = ( {filecontent = self.model:update_filecontent(filename,filecontent), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
- if ( me.filecontent == nil ) then
- list_redir(self)
- else
- return me
- end
- else
- local me = ( {filecontent = self.model:get_filecontent(filename), url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller } )
- if ( me.filecontent == nil ) then
- list_redir(self)
- else
- return me
- end
+ local name = self.clientdata.name or ""
+ if (name == "") then
+ self.conf.action = "status"
+ self.conf.type = "redir"
+ end
+ local modifications = self.clientdata.modifications or ""
+ local cmd = self.clientdata.cmd
+ local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
+
+ if ( modifications ~= "") then
+ modifications = self.model:update_filecontent(name,modifications)
+ end
+
+ if ( cmd ~= nil ) then
+ startstop = self.model:startstop_service( cmd )
+ end
+
+ return ( {name=name,startstop = startstop,
+ status = self.model:getstatus(),
+ file = self.model:get_filedetails(name),
+ modifications = modifications,
+ url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller,
+ confirm_url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller .. "/confirmation", } )
+end
+
+confirmation = function (self)
+ local confirm = self.clientdata.confirm
+ if ( confirm ~= nil ) then
+ startstop = self.model:startstop_service( confirm )
end
+ return ( {startstop = startstop,
+ previousaction = self.clientdata.cmd,
+ status = self.model:getstatus(),
+ confirm_url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller .. "/confirmation",
+ url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller, } )
end