mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
Enable packagers to explicitly provide the configuration file location as a patch
This commit is contained in:
22
configfile.c
22
configfile.c
@@ -95,6 +95,7 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
/*-----------
|
/*-----------
|
||||||
* If no configuration file was provided, attempt to find a default file
|
* If no configuration file was provided, attempt to find a default file
|
||||||
* in this order:
|
* in this order:
|
||||||
|
* - location provided by packager
|
||||||
* - current directory
|
* - current directory
|
||||||
* - /etc/repmgr.conf
|
* - /etc/repmgr.conf
|
||||||
* - default sysconfdir
|
* - default sysconfdir
|
||||||
@@ -102,16 +103,27 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
* here we just check for the existence of the file; parse_config() will
|
* here we just check for the existence of the file; parse_config() will
|
||||||
* handle read errors etc.
|
* handle read errors etc.
|
||||||
*
|
*
|
||||||
* XXX modify this section so package maintainers can provide a patch
|
|
||||||
* specifying location of a distribution-specific configuration file
|
|
||||||
*-----------
|
*-----------
|
||||||
*/
|
*/
|
||||||
if (config_file_provided == false)
|
if (config_file_provided == false)
|
||||||
{
|
{
|
||||||
|
/* packagers: if feasible, patch configuration file path into "package_conf_file" */
|
||||||
|
char package_conf_file[MAXPGPATH] = "";
|
||||||
char my_exec_path[MAXPGPATH] = "";
|
char my_exec_path[MAXPGPATH] = "";
|
||||||
char sysconf_etc_path[MAXPGPATH] = "";
|
char sysconf_etc_path[MAXPGPATH] = "";
|
||||||
|
|
||||||
/* 1. "./repmgr.conf" */
|
/* 1. location provided by packager */
|
||||||
|
if (package_conf_file[0] != '\0')
|
||||||
|
{
|
||||||
|
if (stat(package_conf_file, &stat_config) == 0)
|
||||||
|
{
|
||||||
|
strncpy(config_file_path, package_conf_file, MAXPGPATH);
|
||||||
|
config_file_found = true;
|
||||||
|
goto end_search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2 "./repmgr.conf" */
|
||||||
if (verbose == true)
|
if (verbose == true)
|
||||||
{
|
{
|
||||||
log_notice(_("looking for configuration file in current directory"));
|
log_notice(_("looking for configuration file in current directory"));
|
||||||
@@ -126,7 +138,7 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
goto end_search;
|
goto end_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2. "/etc/repmgr.conf" */
|
/* 3. "/etc/repmgr.conf" */
|
||||||
if (verbose == true)
|
if (verbose == true)
|
||||||
{
|
{
|
||||||
log_notice(_("looking for configuration file in /etc"));
|
log_notice(_("looking for configuration file in /etc"));
|
||||||
@@ -139,7 +151,7 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
goto end_search;
|
goto end_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 3. default sysconfdir */
|
/* 4. default sysconfdir */
|
||||||
if (find_my_exec(argv0, my_exec_path) < 0)
|
if (find_my_exec(argv0, my_exec_path) < 0)
|
||||||
{
|
{
|
||||||
log_error(_("%s: could not find own program executable"), argv0);
|
log_error(_("%s: could not find own program executable"), argv0);
|
||||||
|
|||||||
Reference in New Issue
Block a user