module(..., package.seeall) local list_redir = function (self) self.conf.action = "status" self.conf.type = "redir" error (self.conf) end mvc = {} mvc.on_load = function(self, parent) if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then self.worker[self.conf.action] = list_redir(self) end end function status(self) return { status=self.model.getstatus() } end function config(self) local cmdresult = {} local cmderrors = {} if ( self.clientdata.cmddaemon) then startstop = self.model:startstop_service( self.clientdata.cmddaemon ) end if ( self.clientdata.cmdsave) then local variables="-O -l -S -s -b -L -R" for var in string.gmatch(variables, "%S+") do -- Send nil instead of "" causes the parameter to be removed/deleted/empty/unset if (self.clientdata[var] == "") then self.clientdata[var] = nil end cmdresult[var],cmderrors[var] = self.model:setconfigs("SYSLOGD_OPTS",var,self.clientdata[var]) end end local status = self.model.getstatus() local config, errors = self.model.getconfig() local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller return { status = status, startstop = startstop, clientdata = self.clientdata, cmdresult = cmdresult, config = config, errors = errors, cmderrors = cmderrors, url = url, } end function expert(self) local modifications = self.clientdata.modifications or "" if ( self.clientdata.cmdsave) then modifications = self.model:update_filecontent(modifications) end if ( self.clientdata.cmddaemon) then startstop = self.model:startstop_service( self.clientdata.cmddaemon ) end local status = self.model.getstatus() local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller return { file = self.model:get_filedetails(), status = status, startstop = startstop, clientdata = self.clientdata, url = url, } end