summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2014-11-27 19:47:46 +0000
committerTed Trask <ttrask01@yahoo.com>2014-11-27 19:47:46 +0000
commitc64ba1fb7294f63b3daf69b8aed5d8843c559e95 (patch)
treeba2fc50a12766846484aed6b9b11df34abe7e85d
downloadacf-mysql-c64ba1fb7294f63b3daf69b8aed5d8843c559e95.tar.bz2
acf-mysql-c64ba1fb7294f63b3daf69b8aed5d8843c559e95.tar.xz
Initial commit for acf-mysqlv0.1.0
-rw-r--r--Makefile47
-rw-r--r--README1
-rw-r--r--config.mk10
-rw-r--r--mysql-controller.lua27
-rw-r--r--mysql-details-html.lsp10
l---------mysql-expert-html.lsp1
-rw-r--r--mysql-logfile-html.lsp6
-rw-r--r--mysql-model.lua62
l---------mysql-status-html.lsp1
-rw-r--r--mysql.menu5
-rw-r--r--mysql.roles3
11 files changed, 173 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2c701af
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,47 @@
+APP_NAME=mysql
+PACKAGE=acf-$(APP_NAME)
+VERSION=0.1.0
+
+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 $(DESTDIR)/$(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
diff --git a/README b/README
new file mode 100644
index 0000000..7d37316
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+ACF for mysql
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..45f4d21
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,10 @@
+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
diff --git a/mysql-controller.lua b/mysql-controller.lua
new file mode 100644
index 0000000..d34c368
--- /dev/null
+++ b/mysql-controller.lua
@@ -0,0 +1,27 @@
+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 MySQL 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
diff --git a/mysql-details-html.lsp b/mysql-details-html.lsp
new file mode 100644
index 0000000..831e9f3
--- /dev/null
+++ b/mysql-details-html.lsp
@@ -0,0 +1,10 @@
+<% 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) %>
diff --git a/mysql-expert-html.lsp b/mysql-expert-html.lsp
new file mode 120000
index 0000000..207f324
--- /dev/null
+++ b/mysql-expert-html.lsp
@@ -0,0 +1 @@
+../expert-html.lsp \ No newline at end of file
diff --git a/mysql-logfile-html.lsp b/mysql-logfile-html.lsp
new file mode 100644
index 0000000..e119738
--- /dev/null
+++ b/mysql-logfile-html.lsp
@@ -0,0 +1,6 @@
+<% local data, viewlibrary = ...
+%>
+
+<% if viewlibrary and viewlibrary.dispatch_component then
+ viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="mysql"})
+end %>
diff --git a/mysql-model.lua b/mysql-model.lua
new file mode 100644
index 0000000..2375097
--- /dev/null
+++ b/mysql-model.lua
@@ -0,0 +1,62 @@
+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 = "mysql"
+local packagename = "mysql"
+
+local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin "
+
+local filelist
+
+-- ################################################################################
+-- 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, "MySQL Status")
+end
+
+function mymodule.getstatusdetails()
+ local retval = cfe({ type="longtext", value="", label="MySQL 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
diff --git a/mysql-status-html.lsp b/mysql-status-html.lsp
new file mode 120000
index 0000000..b2f8480
--- /dev/null
+++ b/mysql-status-html.lsp
@@ -0,0 +1 @@
+../status-html.lsp \ No newline at end of file
diff --git a/mysql.menu b/mysql.menu
new file mode 100644
index 0000000..0ead445
--- /dev/null
+++ b/mysql.menu
@@ -0,0 +1,5 @@
+#CAT GROUP/DESC TAB ACTION
+Applications 25MySQL Status details
+Applications 25MySQL Expert expert
+Applications 25MySQL Databases listdatabases
+Applications 25MySQL Logfile logfile
diff --git a/mysql.roles b/mysql.roles
new file mode 100644
index 0000000..e791027
--- /dev/null
+++ b/mysql.roles
@@ -0,0 +1,3 @@
+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