Changed data directory to /var/lib/maxscale.

This commit is contained in:
Markus Makela
2015-05-22 11:31:22 +03:00
parent 6d9765f736
commit 0d85ae6603
6 changed files with 22 additions and 9 deletions

View File

@ -120,7 +120,7 @@ char fname[1024], *home;
char uname[80], passwd[80]; char uname[80], passwd[80];
initialise(); initialise();
sprintf(fname, "%s/passwd", get_cachedir()); sprintf(fname, "%s/passwd", get_datadir());
if ((fp = fopen(fname, "r")) == NULL) if ((fp = fopen(fname, "r")) == NULL)
return NULL; return NULL;
if ((rval = users_alloc()) == NULL) if ((rval = users_alloc()) == NULL)
@ -151,7 +151,7 @@ FILE *fp;
char fname[1024], *home, *cpasswd; char fname[1024], *home, *cpasswd;
initialise(); initialise();
sprintf(fname, "%s/passwd", get_cachedir()); sprintf(fname, "%s/passwd", get_datadir());
if (users == NULL) if (users == NULL)
{ {
@ -244,8 +244,8 @@ char* admin_remove_user(
/** /**
* Open passwd file and remove user from the file. * Open passwd file and remove user from the file.
*/ */
sprintf(fname, "%s/passwd", get_cachedir()); sprintf(fname, "%s/passwd", get_datadir());
sprintf(fname_tmp, "%s/passwd_tmp", get_cachedir()); sprintf(fname_tmp, "%s/passwd_tmp", get_datadir());
/** /**
* Rewrite passwd file from memory. * Rewrite passwd file from memory.
*/ */

View File

@ -1047,6 +1047,7 @@ int main(int argc, char **argv)
break; break;
case 'D': case 'D':
sprintf(datadir,"%s",optarg); sprintf(datadir,"%s",optarg);
maxscaledatadir = strdup(optarg);
datadir_defined = true; datadir_defined = true;
break; break;
case 'C': case 'C':

View File

@ -17,3 +17,13 @@ char* get_cachedir()
{ {
return cachedir?cachedir:(char*)default_cachedir; return cachedir?cachedir:(char*)default_cachedir;
} }
/**
* Get the service cache directory
* @return The path to the cache directory
*/
char* get_datadir()
{
return maxscaledatadir?maxscaledatadir:(char*)default_datadir;
}

View File

@ -71,7 +71,7 @@ int fd;
int len; int len;
static int reported = 0; static int reported = 0;
snprintf(secret_file, PATH_MAX, "%s/.secrets", get_cachedir()); snprintf(secret_file, PATH_MAX, "%s/.secrets", get_datadir());
/* Try to access secrets file */ /* Try to access secrets file */
if (access(secret_file, R_OK) == -1) if (access(secret_file, R_OK) == -1)

View File

@ -26,7 +26,7 @@ static const char* default_cnf_fname = "maxscale.cnf";
static const char* default_configdir = "/etc/"; static const char* default_configdir = "/etc/";
static const char* default_piddir = "/var/run/maxscale/"; static const char* default_piddir = "/var/run/maxscale/";
static const char* default_logdir = "/var/log/maxscale/"; static const char* default_logdir = "/var/log/maxscale/";
static const char* default_datadir = "/var/cache/maxscale/"; static const char* default_datadir = "/var/lib/maxscale/";
static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@"; static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@";
static const char* default_cachedir = "/var/cache/maxscale/"; static const char* default_cachedir = "/var/cache/maxscale/";
static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale/"; static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale/";
@ -35,8 +35,10 @@ static char* configdir = NULL;
static char* logdir = NULL; static char* logdir = NULL;
static char* libdir = NULL; static char* libdir = NULL;
static char* cachedir = NULL; static char* cachedir = NULL;
static char* maxscaledatadir = NULL;
static char* langdir = NULL; static char* langdir = NULL;
char* get_libdir(); char* get_libdir();
char* get_datadir();
char* get_cachedir(); char* get_cachedir();
#endif #endif

View File

@ -79,7 +79,7 @@ struct dirent *dp;
if (router->binlogdir == NULL) if (router->binlogdir == NULL)
{ {
strcpy(path, get_cachedir()); strcpy(path, get_datadir());
strncat(path,"/",PATH_MAX); strncat(path,"/",PATH_MAX);
strncat(path, router->service->name,PATH_MAX); strncat(path, router->service->name,PATH_MAX);
@ -658,7 +658,7 @@ blr_cache_response(ROUTER_INSTANCE *router, char *response, GWBUF *buf)
char path[PATH_MAX+1], *ptr; char path[PATH_MAX+1], *ptr;
int fd; int fd;
strcpy(path,get_cachedir()); strcpy(path,get_datadir());
strncat(path,"/",PATH_MAX); strncat(path,"/",PATH_MAX);
strncat(path, router->service->name, PATH_MAX); strncat(path, router->service->name, PATH_MAX);
@ -693,7 +693,7 @@ char path[PATH_MAX+1], *ptr;
int fd; int fd;
GWBUF *buf; GWBUF *buf;
strcpy(path, get_cachedir()); strcpy(path, get_datadir());
strncat(path, "/", PATH_MAX); strncat(path, "/", PATH_MAX);
strncat(path, router->service->name, PATH_MAX); strncat(path, router->service->name, PATH_MAX);
strncat(path, "/.cache/", PATH_MAX); strncat(path, "/.cache/", PATH_MAX);