1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
-- 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 <i><b>/var/log/messages</b></i><BR><font style='color:f00'>(Still working on this function)</font>"
} )
]]--
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 <i><b>/etc/openvpn/</b></i><br>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 <i><b>/etc/openvpn/*.conf</b></i>"
}
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
-- <prefix>/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
|