diff options
Diffstat (limited to 'openntpd-controller.lua')
-rw-r--r-- | openntpd-controller.lua | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/openntpd-controller.lua b/openntpd-controller.lua index b7d8c8e..7031263 100644 --- a/openntpd-controller.lua +++ b/openntpd-controller.lua @@ -45,6 +45,7 @@ config = function (self) end if (self.clientdata.hosts_type == nil) then errors["hosts_type"]="You need to choose type of server" + errors["hosts_add_orgvalue"] = self.clientdata.hosts_add end if (self.clientdata.hosts_add ~= "") and (self.clientdata.hosts_type ~= nil) then modify_opts = self.model:modify_config(hosts_cmd, nil, self.clientdata.hosts_type .. " " .. self.clientdata.hosts_add) @@ -73,58 +74,44 @@ config = function (self) DEBUGMODEL = modify_opts -- <<< DEBUG INFO >>> DEBUGCLIENTDATA = self.clientdata -- <<< DEBUG INFO >>> + local startstop if ( cmd ~= nil ) then - local startstop = self.model:startstop_service( cmd ) - posix.sleep(1) -- Wait for the process to start|stop - return ( {status = self.model:get(), - startstop = "", - modify_opts=modify_opts, - url = url } ) - else - return ( {status = self.model:get(), startstop = "", - errors = errors, - modify_opts=modify_opts, - url = url, - DEBUGMODEL=DEBUGMODEL, - DEBUGCLIENTDATA=DEBUGCLIENTDATA } ) + startstop = self.model:startstop_service( cmd ) end + return ( {status = self.model:getstatus(), + config = self.model:getconfig(), + url = url, + errors = errors, + startstop = startstop, } ) 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 status = function (self) local cmd = self.clientdata.cmd local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller - return ( {status = self.model:get(), url = url } ) + return ( {status = self.model:getstatus(), url = url } ) end expert = function (self) - local file = self.clientdata.modifications or "" + local modifications = self.clientdata.modifications or "" local cmd = self.clientdata.cmd local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller - if ( file ~= "") then - local me = ( {file = self.model:update_filecontent(file), url = url } ) - return ( {startstop = "", - status = self.model:get(), - file = self.model:get_filecontent(), - url = url } ) - else - if ( cmd ~= nil ) then - local startstop = self.model:startstop_service( cmd ) - posix.sleep(1) -- Wait for the process to start|stop - return ( {startstop = startstop, - status = self.model:get(), - filec = self.model:get_filecontent(), - url = url } ) - else - return ( {startstop = "", - status = self.model:get(), - file = self.model:get_filecontent(), - url = url } ) - end + if ( modifications ~= "") then + modifications = self.model:update_filecontent(modifications) + end + + if ( cmd ~= nil ) then + startstop = self.model:startstop_service( cmd ) end + + return ( {startstop = startstop, + status = self.model:getstatus(), + file = self.model:get_filedetails(), + modifications = modifications, + url = url, } ) end |