Commit 6898d431 authored by Ted Trask's avatar Ted Trask
Browse files

Initial commit for acf-mariadb based on acf-mysql-0.1.1

parents
APP_NAME=mariadb
PACKAGE=acf-$(APP_NAME)
VERSION=0.1.1
APP_DIST=\
mysql* \
EXTRA_DIST=README Makefile config.mk
DISTFILES=$(APP_DIST) $(EXTRA_DIST)
TAR=tar
P=$(PACKAGE)-$(VERSION)
tarball=$(P).tar.bz2
install_dir=$(DESTDIR)/$(appdir)/$(APP_NAME)
all:
clean:
rm -rf $(tarball) $(P)
dist: $(tarball)
install:
mkdir -p "$(install_dir)"
cp -a $(APP_DIST) "$(install_dir)"
for i in $$(ls -1 $(acflibdir)/db-*.lsp); do\
ln -sf ../../lib/$$(basename $$i) $(install_dir)/$$(echo "$$(basename $$i)" | sed "s/db/$(APP_NAME)/");\
done
$(tarball): $(DISTFILES)
rm -rf $(P)
mkdir -p $(P)
cp -a $(DISTFILES) $(P)
$(TAR) -jcf $@ $(P)
rm -rf $(P)
# target that creates a tar package, unpacks is and install from package
dist-install: $(tarball)
$(TAR) -jxf $(tarball)
$(MAKE) -C $(P) install DESTDIR=$(DESTDIR)
rm -rf $(P)
include config.mk
.PHONY: all clean dist install dist-install
ACF for mariadb
prefix=/usr
datadir=${prefix}/share
sysconfdir=${prefix}/etc
localstatedir=${prefix}/var
acfdir=${datadir}/acf
wwwdir=${acfdir}/www
cgibindir=${acfdir}/cgi-bin
appdir=${acfdir}/app
acflibdir=${acfdir}/lib
sessionsdir=${localstatedir}/lib/acf/sessions
local mymodule = {}
mymodule.default_action = "status"
function mymodule.status(self)
return self.model.getstatus()
end
function mymodule.startstop(self)
return self.handle_form(self, self.model.get_startstop, self.model.startstop_service, self.clientdata)
end
function mymodule.details(self)
return self.model.getstatusdetails()
end
function mymodule.expert(self)
return self.handle_form(self, self.model.getfiledetails, self.model.updatefiledetails, self.clientdata, "Save", "Edit MariaDB File", "File Saved")
end
-- Use acf-db to allow editing of the database
dbcontrollerfunctions = require("dbcontrollerfunctions")
for n,f in pairs(dbcontrollerfunctions) do
mymodule[n] = f
end
return mymodule
<% local data, viewlibrary, page_info, session = ...
htmlviewfunctions = require("htmlviewfunctions")
html = require("acf.html")
%>
<% viewlibrary.dispatch_component("status") %>
<% local header_level = htmlviewfunctions.displaysectionstart(data, page_info) %>
<% htmlviewfunctions.displayitem(data) %>
<% htmlviewfunctions.displaysectionend(header_level) %>
../expert-html.lsp
\ No newline at end of file
<% local data, viewlibrary = ...
%>
<% if viewlibrary and viewlibrary.dispatch_component then
viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="mysql"})
end %>
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
for n,f in pairs(dbmodelfunctions) do
mymodule[n] = function(...)
return f(determineconnection, ...)
end
end
return mymodule
../status-html.lsp
\ No newline at end of file
#CAT GROUP/DESC TAB ACTION
Applications 25MariaDB Status details
Applications 25MariaDB Expert expert
Applications 25MariaDB Databases listdatabases
Applications 25MariaDB Logfile logfile
USER=mysql:status,mysql:logfile,mysql:details,mysql:startstop
EXPERT=mysql:expert
ADMIN=mysql:status,mysql:logfile,mysql:details,mysql:startstop,mysql:expert,mysql:listdatabases,mysql:listtables,mysql:viewtable,mysql:deletetableentry,mysql:updatetableentry,mysql:createtableentry
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment