Commit e34be123 authored by Ted Trask's avatar Ted Trask

Read data path from conf.d file, rather than hardcoded.

parent c2e87095
......@@ -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
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