Store persisted config directory
The persisted configuration subdirectory will be used to store changes to the configuration. The gwdirs.h header now supports setting and getting the value for this directory.
This commit is contained in:
parent
4b82f83637
commit
ec894f41b8
@ -20,6 +20,7 @@ set(DEFAULT_CACHE_SUBPATH "cache/maxscale" CACHE PATH "Default cache subpath")
|
||||
set(DEFAULT_LANG_SUBPATH "lib/maxscale" CACHE PATH "Default language file subpath")
|
||||
set(DEFAULT_EXEC_SUBPATH "${MAXSCALE_BINDIR}" CACHE PATH "Default executable subpath")
|
||||
set(DEFAULT_CONFIG_SUBPATH "etc" CACHE PATH "Default configuration subpath")
|
||||
set(DEFAULT_CONFIG_PERSIST_SUBPATH "maxscale.cnf.d" CACHE PATH "Default persisted configuration subpath")
|
||||
|
||||
set(DEFAULT_PIDDIR ${MAXSCALE_VARDIR}/${DEFAULT_PID_SUBPATH} CACHE PATH "Default PID file directory")
|
||||
set(DEFAULT_LOGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LOG_SUBPATH} CACHE PATH "Default log directory")
|
||||
@ -29,6 +30,7 @@ set(DEFAULT_CACHEDIR ${MAXSCALE_VARDIR}/${DEFAULT_CACHE_SUBPATH} CACHE PATH "Def
|
||||
set(DEFAULT_LANGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LANG_SUBPATH} CACHE PATH "Default language file directory")
|
||||
set(DEFAULT_EXECDIR ${CMAKE_INSTALL_PREFIX}/${DEFAULT_EXEC_SUBPATH} CACHE PATH "Default executable directory")
|
||||
set(DEFAULT_CONFIGDIR /${DEFAULT_CONFIG_SUBPATH} CACHE PATH "Default configuration directory")
|
||||
set(DEFAULT_CONFIG_PERSISTDIR ${DEFAULT_DATADIR}/${DEFAULT_CONFIG_PERSIST_SUBPATH} CACHE PATH "Default persisted configuration directory")
|
||||
|
||||
# Massage TARGET_COMPONENT into a list
|
||||
if (TARGET_COMPONENT)
|
||||
|
@ -32,10 +32,12 @@ MXS_BEGIN_DECLS
|
||||
#define MXS_DEFAULT_LANG_SUBPATH "@DEFAULT_LANG_SUBPATH@"
|
||||
#define MXS_DEFAULT_EXEC_SUBPATH "@DEFAULT_EXEC_SUBPATH@"
|
||||
#define MXS_DEFAULT_CONFIG_SUBPATH "@DEFAULT_CONFIG_SUBPATH@"
|
||||
#define MXS_DEFAULT_CONFIG_PERSIST_SUBPATH "@DEFAULT_CONFIG_PERSIST_SUBPATH@"
|
||||
|
||||
/** Default file locations, configured by CMake */
|
||||
static const char* default_cnf_fname = "maxscale.cnf";
|
||||
static const char* default_configdir = "@DEFAULT_CONFIGDIR@";
|
||||
|
||||
/*< This should be changed to just /run eventually,
|
||||
* the /var/run folder is an old standard and the newer FSH 3.0
|
||||
* uses /run for PID files.*/
|
||||
@ -46,8 +48,10 @@ static const char* default_libdir = "@DEFAULT_LIBDIR@";
|
||||
static const char* default_cachedir = "@DEFAULT_CACHEDIR@";
|
||||
static const char* default_langdir = "@DEFAULT_LANGDIR@";
|
||||
static const char* default_execdir = "@DEFAULT_EXECDIR@";
|
||||
static const char* default_config_persistdir = "@DEFAULT_CONFIG_PERSISTDIR@";
|
||||
|
||||
static char* configdir = NULL;
|
||||
static char* configdir = NULL; /*< Where the config file is found e.g. /etc/ */
|
||||
static char* config_persistdir = NULL;/*< Persisted configs e.g. /var/lib/maxscale.cnf.d/ */
|
||||
static char* logdir = NULL;
|
||||
static char* libdir = NULL;
|
||||
static char* cachedir = NULL;
|
||||
@ -62,6 +66,7 @@ void set_datadir(char* param);
|
||||
void set_process_datadir(char* param);
|
||||
void set_cachedir(char* param);
|
||||
void set_configdir(char* param);
|
||||
void set_config_persistdir(char* param);
|
||||
void set_logdir(char* param);
|
||||
void set_langdir(char* param);
|
||||
void set_piddir(char* param);
|
||||
@ -71,6 +76,7 @@ char* get_datadir();
|
||||
char* get_process_datadir();
|
||||
char* get_cachedir();
|
||||
char* get_configdir();
|
||||
char* get_config_persistdir();
|
||||
char* get_piddir();
|
||||
char* get_logdir();
|
||||
char* get_langdir();
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include <maxscale/service.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
#include <maxscale/utils.h>
|
||||
#include <maxscale/gwdirs.h>
|
||||
|
||||
typedef struct duplicate_context
|
||||
{
|
||||
|
@ -26,6 +26,17 @@ void set_configdir(char* str)
|
||||
configdir = str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the configuration parts file directory
|
||||
* @param str Path to directory
|
||||
*/
|
||||
void set_config_persistdir(char* str)
|
||||
{
|
||||
MXS_FREE(config_persistdir);
|
||||
clean_up_pathname(str);
|
||||
config_persistdir = str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the log file directory
|
||||
* @param str Path to directory
|
||||
@ -160,6 +171,15 @@ char* get_configdir()
|
||||
return configdir ? configdir : (char*) default_configdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration file directory
|
||||
* @return The path to the configuration file directory
|
||||
*/
|
||||
char* get_config_persistdir()
|
||||
{
|
||||
return config_persistdir ? config_persistdir : (char*) default_config_persistdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PID file directory which contains maxscale.pid
|
||||
* @return Path to the PID file directory
|
||||
|
Loading…
x
Reference in New Issue
Block a user