summaryrefslogtreecommitdiffstats
path: root/postgresql-model.lua
diff options
context:
space:
mode:
Diffstat (limited to 'postgresql-model.lua')
-rw-r--r--postgresql-model.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/postgresql-model.lua b/postgresql-model.lua
index 90aa30c..5efa635 100644
--- a/postgresql-model.lua
+++ b/postgresql-model.lua
@@ -6,18 +6,26 @@ require("fs")
require("format")
-- Set variables
+local confdfile = "/etc/conf.d/postgresql"
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 datadirectory
+local filelist
-- ################################################################################
-- LOCAL FUNCTIONS
+local determinefilelist = function()
+ if not filelist then
+ datadirectory = format.get_ini_entry(fs.read_file(confdfile) or "", "", "PGDATA")
+ filelist = fs.find_files_as_array(".*%.conf", datadirectory)
+ end
+ return filelist
+end
+
-- ################################################################################
-- PUBLIC FUNCTIONS
@@ -36,7 +44,7 @@ end
function getfilelist()
local listed_files = {}
- for i,name in ipairs(filelist) do
+ for i,name in ipairs(determinefilelist()) do
local filedetails = fs.stat(name) or {}
table.insert ( listed_files , {filename=name, mtime=filedetails.mtime or "---", filesize=filedetails.size or "0"} )
end
@@ -47,9 +55,9 @@ function getfilelist()
end
function getfiledetails(filename)
- return modelfunctions.getfiledetails(filename, filelist)
+ return modelfunctions.getfiledetails(filename, determinefilelist())
end
function updatefiledetails(filedetails)
- return modelfunctions.setfiledetails(filedetails, filelist)
+ return modelfunctions.setfiledetails(filedetails, determinefilelist())
end