diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-03-03 21:55:09 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-03-03 21:55:09 +0000 |
commit | 64a4cac9126cb6d79fc243cdb65ae22e6c3d6350 (patch) | |
tree | e5215ce4c219aef474241b5974ebc0396457e25e | |
download | acf-postgresql-64a4cac9126cb6d79fc243cdb65ae22e6c3d6350.tar.bz2 acf-postgresql-64a4cac9126cb6d79fc243cdb65ae22e6c3d6350.tar.xz |
Added postgresql first cut.
git-svn-id: svn://svn.alpinelinux.org/acf/postgresql/trunk@1726 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r-- | Makefile | 44 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | config.mk | 10 | ||||
-rw-r--r-- | postgresql-controller.lua | 26 | ||||
-rw-r--r-- | postgresql-details-html.lsp | 17 | ||||
l--------- | postgresql-expert-html.lsp | 1 | ||||
-rw-r--r-- | postgresql-listfiles-html.lsp | 39 | ||||
-rw-r--r-- | postgresql-logfile-html.lsp | 7 | ||||
-rw-r--r-- | postgresql-model.lua | 86 | ||||
-rw-r--r-- | postgresql-startstop-html.lsp | 24 | ||||
l--------- | postgresql-status-html.lsp | 1 | ||||
-rw-r--r-- | postgresql.menu | 4 | ||||
-rw-r--r-- | postgresql.roles | 3 |
13 files changed, 263 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b69fe20 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +APP_NAME=postgresql +PACKAGE=acf-$(APP_NAME) +VERSION=0.1.1 + +APP_DIST=\ + postgresql* \ + + +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)" + +$(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 @@ -0,0 +1 @@ +ACF for postgresql 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/postgresql-controller.lua b/postgresql-controller.lua new file mode 100644 index 0000000..cf6301f --- /dev/null +++ b/postgresql-controller.lua @@ -0,0 +1,26 @@ +module(..., package.seeall) + +-- Load libraries +require("controllerfunctions") + +default_action = "status" + +function status(self) + return self.model.getstatus() +end + +function startstop(self) + return controllerfunctions.handle_startstop(self, self.model.startstop_service, self.model.getstatus, self.clientdata) +end + +function details(self) + return self.model.getstatusdetails() +end + +function listfiles(self) + return self.model.getfilelist() +end + +function expert(self) + return controllerfunctions.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit Postgresql File", "File Saved") +end diff --git a/postgresql-details-html.lsp b/postgresql-details-html.lsp new file mode 100644 index 0000000..b8a4ce7 --- /dev/null +++ b/postgresql-details-html.lsp @@ -0,0 +1,17 @@ +<% local data, viewlibrary = ... +require("viewfunctions") +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(data)) +io.write("</span>") +--]] +%> + +<% viewlibrary.dispatch_component("status") %> + +<H2><%= html.html_escape(data.label) %></H2> +<DL> +<% +displayitem(data) +%> +</DL> diff --git a/postgresql-expert-html.lsp b/postgresql-expert-html.lsp new file mode 120000 index 0000000..207f324 --- /dev/null +++ b/postgresql-expert-html.lsp @@ -0,0 +1 @@ +../expert-html.lsp
\ No newline at end of file diff --git a/postgresql-listfiles-html.lsp b/postgresql-listfiles-html.lsp new file mode 100644 index 0000000..f94653b --- /dev/null +++ b/postgresql-listfiles-html.lsp @@ -0,0 +1,39 @@ +<% local data, viewlibrary, page_info, session = ... +require("viewfunctions") +%> +<% +--[[ DEBUG INFORMATION +io.write("<H1>DEBUGGING</H1><span style='color:red'><H2>DEBUG INFO: CFE</H2>") +io.write(html.cfe_unpack(data)) +io.write("</span>") +--]] +%> + +<% displaycommandresults({"expert", "startstop"}, session) %> + +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("status") +end %> + +<h1><%= html.html_escape(data.label) %></h1> + +<TABLE> + <TR style="background:#eee;font-weight:bold;"> + <TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">File</TD> + <TD style="padding-right:20px;white-space:nowrap;text-align:left;" class="header">Size</TD> + <TD style="white-space:nowrap;text-align:left;" class="header">Last Modified</TD> + </TR> + + +<% for i,file in ipairs(data.value) do %> + <TR> + <TD style="padding-right:20px;white-space:nowrap;"><%= html.link{value = "expert?filename=" .. file.filename.."&redir="..page_info.orig_action, label=file.filename} %></TD> + <TD style="padding-right:20px;white-space:nowrap;"><%= html.html_escape(file.filesize) %></TD> + <TD style="white-space:nowrap;" width="90%"><%= html.html_escape(file.mtime) %></TD> + </TR> +<% end %> +</TABLE> + +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("startstop") +end %> diff --git a/postgresql-logfile-html.lsp b/postgresql-logfile-html.lsp new file mode 100644 index 0000000..4f2e388 --- /dev/null +++ b/postgresql-logfile-html.lsp @@ -0,0 +1,7 @@ +<% local data, viewlibrary = ... +require("viewfunctions") +%> + +<% if viewlibrary and viewlibrary.dispatch_component then + viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {name="/var/log/messages", grep="postgres"}) +end %> diff --git a/postgresql-model.lua b/postgresql-model.lua new file mode 100644 index 0000000..5ea63a0 --- /dev/null +++ b/postgresql-model.lua @@ -0,0 +1,86 @@ +module(..., package.seeall) + +-- Load libraries +require("modelfunctions") +require("fs") +require("format") + +-- Set variables +local processname = "postgresql" +local packagename = "postgresql" +local datadirectory = "/var/lib/postgresql/data/" +local pidfile = "postmaster.pid" + +local path = "PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin " + +local filelist = fs.find_files_as_array(".*\.conf", datadirectory) + +-- ################################################################################ +-- LOCAL FUNCTIONS + +-- ################################################################################ +-- PUBLIC FUNCTIONS + +function startstop_service(action) + -- Custom startstop to enable setup option + local result = cfe({ label="Start/Stop result" }) + + if (string.lower(action) == "start") or (string.lower(action) == "stop") or (string.lower(action) == "restart") or (string.lower(action) == "setup") then + local file = io.popen(path .. "/etc/init.d/" .. processname .. " " .. string.lower(action) .. " 2>&1" ) + if file ~= nil then + result.value = file:read( "*a" ) or "" + file:close() + end + posix.sleep(2)-- Wait for the process to start|stop + else + result.errtxt = "Unknown command!" + end + + return result +end + +function getstatus() + local status = modelfunctions.getstatus(processname, packagename, "Postgresql Status") + + -- Enabled status is unique for postgresql + -- Look for pid file stored in data_directory .. /postmaster.pid + local file = datadirectory .. pidfile + -- check to see if there's a matching proc directory and that it was created slightly after the pid file + -- this allows us to avoid the problem with proc numbers wrapping + local tmp = string.match(fs.read_file(file) or "", "%d+") + if tmp then + local dir = "/proc/" .. tmp + filetime = posix.stat(file, "ctime") + dirtime = posix.stat(dir, "ctime") + if dirtime and (tonumber(dirtime) - tonumber(filetime) < 100) then + status.value.status.value = "Running" + end + end + + return status +end + +function getstatusdetails() + return cfe({ type="longtext", value="", label="Postgresql Status Details" }) +end + +function getfilelist() + local listed_files = {} + + for i,name in ipairs(filelist) do + local filedetails = fs.stat(name) or {} + table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} ) + end + + table.sort(listed_files, function (a,b) return (a.filename < b.filename) end ) + + return cfe({ type="list", value=listed_files, label="Postgresql File List" }) +end + +function getfiledetails(filename) + return modelfunctions.getfiledetails(filename, filelist) +end + +function updatefiledetails(filedetails) + return modelfunctions.setfiledetails(filedetails, filelist) +end diff --git a/postgresql-startstop-html.lsp b/postgresql-startstop-html.lsp new file mode 100644 index 0000000..dbecda9 --- /dev/null +++ b/postgresql-startstop-html.lsp @@ -0,0 +1,24 @@ +<% local data, viewlibrary, page_info = ... %> + +<H1>Management</H1> +<DL> +<form action="<%= html.html_escape(page_info.script .. page_info.prefix .. page_info.controller .. "/" .. page_info.action) %>" method="POST"> +<DT>Program control-panel</DT> +<DD> +<input class="submit" type="submit" name="action" value="Setup" <% if data.value.status.value== "Running" then io.write("disabled") end %>> +<input class="submit" type="submit" name="action" value="Start" <% if data.value.status.value== "Running" then io.write("disabled") end %>> +<input class="submit" type="submit" name="action" value="Stop" <% if data.value.status.value== "Stopped" then io.write("disabled") end %>> +<input class="submit" type="submit" name="action" value="Restart" <% if data.value.status.value== "Stopped" then io.write("disabled") end %>> +</DD> +</form> + +<% if data.value.result then %> +<DT>Previous action result</DT> +<DD> +<% if data.value.result.value ~= "" then %> +<P CLASS='descr'><%= string.gsub(html.html_escape(data.value.result.value), "\n", "<BR>") %></P> +<% end if data.value.result.errtxt then %> +<P CLASS='error'><%= string.gsub(html.html_escape(data.value.result.errtxt), "\n", "<BR>") %></P> +<% end end %> +</DD> +</DL> diff --git a/postgresql-status-html.lsp b/postgresql-status-html.lsp new file mode 120000 index 0000000..b2f8480 --- /dev/null +++ b/postgresql-status-html.lsp @@ -0,0 +1 @@ +../status-html.lsp
\ No newline at end of file diff --git a/postgresql.menu b/postgresql.menu new file mode 100644 index 0000000..d864964 --- /dev/null +++ b/postgresql.menu @@ -0,0 +1,4 @@ +#CAT GROUP/DESC TAB ACTION +Applications 60Postgresql Status status +Applications 60Postgresql Expert listfiles +Applications 60Postgresql Logfile logfile diff --git a/postgresql.roles b/postgresql.roles new file mode 100644 index 0000000..8e3f58e --- /dev/null +++ b/postgresql.roles @@ -0,0 +1,3 @@ +USER=postgresql:status,postgresql:logfile,postgresql:details,postgresql:startstop +EXPERT=postgresql:listfiles,postgresql:expert +ADMIN=postgresql:status,postgresql:logfile,postgresql:details,postgresql:startstop,postgresql:listfiles,postgresql:expert |