diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-07-02 15:06:28 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-07-02 15:06:28 +0000 |
commit | e34be1236742c6b1ff2030ae5c1e809f37a2266c (patch) | |
tree | d2a18b6cf58b70cba11e72ff6ea18e22d7165445 /postgresql-model.lua | |
parent | c2e87095217c8996c88fbb3442a11b06b38eb733 (diff) | |
download | acf-postgresql-e34be1236742c6b1ff2030ae5c1e809f37a2266c.tar.bz2 acf-postgresql-e34be1236742c6b1ff2030ae5c1e809f37a2266c.tar.xz |
Read data path from conf.d file, rather than hardcoded.
Diffstat (limited to 'postgresql-model.lua')
-rw-r--r-- | postgresql-model.lua | 20 |
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 |