-- the hostname controller module (..., package.seeall) -- Cause an http redirect to our "read" action -- We use the self.conf table because it already has prefix,controller,etc -- The redir code is defined in the application error handler (acf-controller) local list_redir = function (self) self.conf.action = "read" 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 -- logit ("hostname.mvc.on_load activated") end local function build_form ( model ) local viewtable = {} local configform = {} local processform = {} local messageform = {} -- local conflist = model.conflist() local conflist = "hej" local formwith = 60 -- cf.self is a global variable specifiying this controller -- local url = cf.self or "" --[[ table.insert ( messageform , { type = "label" , value = "Logfile info" , text = "Tail file /var/log/messages
(Still working on this function)" } ) ]]-- table.insert ( processform , { type = "label" , value = "Process information", text = "Information on if process is running." } ) table.insert ( processform , { type = "formtext", label = "openvpn process status", -- value = model.status("openvpn") value = "hej" } ) -- if table.maxn(conflist)==0 then if 0==0 then table.insert ( configform , { type = "label" , value = "List of valid configurations" , text = "No valid configurations could be found in /etc/openvpn/
A valid config is called *.conf and has got at least the following parameters set: ca, cert, key, dev, proto (and for clients also parameter 'remote')" } ) else -- Generate processlist configform[1] = { type = "label", value = "List of valid configurations" , text = "List is based on all valid configuration files named /etc/openvpn/*.conf" } for i=1,table.maxn(conflist) do table.insert ( configform , { type = "formtext" , -- label = conflist[i].confname , label = "hej" , -- value = conflist[i].conftype or "" value = "hej" or "" } ) end end --- Define the main table used by the generic view renderer viewtable[1] = { type = "label", value = "GENERAL" } viewtable[2] = { type = "form", method = "post", action = "set", -- Put the 'form' table in the view table value = processform } viewtable[3] = { type = "form", method = "post", action = "set", --action = cf.self .. "/set", -- Put the 'form' table in the view table value = configform } viewtable[4] = { type = "form", method = "post", action = "set", --action = cf.self .. "/set", -- Put the 'form' table in the view table value = messageform } return viewtable end -- Public methods -- /hostname/get read = function (self) local me = {} me = cfe{name=conflistfilesaf, value="hej"} return ( {conflistfiles = self.model:list_conffiles()} ) -- return ({conflistfiles = me}) -- return self.model:get() -- return build_form(self) end server_config = function (self) end create = update