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
|
local mymodule = {}
-- Load libraries
modelfunctions = require("modelfunctions")
fs = require("acf.fs")
format = require("acf.format")
db = require("acf.db")
dbmodelfunctions = require("dbmodelfunctions")
-- Set variables
local conffile = "/etc/mysql/my.cnf"
local processname = "mariadb"
local packagename = "mariadb"
-- ################################################################################
-- LOCAL FUNCTIONS
local determineconnection = function()
local port = format.parse_ini_file(fs.read_file(conffile), "client", "port")
return db.create(db.engine.mysql, nil, nil, nil, "", tonumber(port) or 3306)
end
-- ################################################################################
-- PUBLIC FUNCTIONS
function mymodule.get_startstop(self, clientdata)
return modelfunctions.get_startstop(processname)
end
function mymodule.startstop_service(self, startstop, action)
return modelfunctions.startstop_service(startstop, action)
end
function mymodule.getstatus()
return modelfunctions.getstatus(processname, packagename, "MariaDB Status")
end
function mymodule.getstatusdetails()
local retval = cfe({ type="longtext", value="", label="MariaDB Status Details" })
retval.value, retval.errtxt = modelfunctions.run_executable({"mysqladmin", "extended-status"})
return retval
end
function mymodule.getfiledetails()
return modelfunctions.getfiledetails(conffile, {conffile})
end
function mymodule.updatefiledetails(self, filedetails)
return modelfunctions.setfiledetails(self, filedetails, {conffile})
end
function mymodule.get_logfile(self, clientdata)
local retval = cfe({ type="group", value={}, label="Log File Configuration" })
retval.value.facility = cfe({value="daemon", label="Syslog Facility"})
retval.value.grep = cfe({ value="mariadb", label="Grep" })
return retval
end
for n,f in pairs(dbmodelfunctions) do
mymodule[n] = function(...)
return f(determineconnection, ...)
end
end
return mymodule
|