Permit custom locations for astdb and the keys directory (though default to the curre...
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 24 Sep 2007 22:06:19 +0000 (22:06 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 24 Sep 2007 22:06:19 +0000 (22:06 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@83726 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
main/asterisk.c

index b9d31bf..943fbeb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -108,6 +108,8 @@ ifeq ($(OSARCH),SunOS)
   ASTETCDIR=/var/etc/asterisk
   ASTLIBDIR=/opt/asterisk/lib
   ASTVARLIBDIR=/var/opt/asterisk
+  ASTDBDIR=$(ASTVARLIBDIR)
+  ASTKEYDIR=$(ASTVARLIBDIR)
   ASTSPOOLDIR=/var/spool/asterisk
   ASTLOGDIR=/var/log/asterisk
   ASTHEADERDIR=/opt/asterisk/include
@@ -128,9 +130,12 @@ else
 ifneq ($(findstring BSD,$(OSARCH)),)
   ASTVARLIBDIR=$(prefix)/share/asterisk
   ASTVARRUNDIR=$(localstatedir)/run/asterisk
+  ASTDBDIR=$(localstatedir)/db/asterisk
 else
   ASTVARLIBDIR=$(localstatedir)/lib/asterisk
+  ASTDBDIR=$(ASTVARLIBDIR)
 endif
+  ASTKEYDIR=$(ASTVARLIBDIR)
 endif
 ifeq ($(ASTDATADIR),)
   ASTDATADIR:=$(ASTVARLIBDIR)
@@ -556,6 +561,8 @@ samples: adsi
                echo "astetcdir => $(ASTETCDIR)" ; \
                echo "astmoddir => $(MODULES_DIR)" ; \
                echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
+               echo "astdbdir => $(ASTDBDIR)" ; \
+               echo "astkeydir => $(ASTKEYDIR)" ; \
                echo "astdatadir => $(ASTDATADIR)" ; \
                echo "astagidir => $(AGI_DIR)" ; \
                echo "astspooldir => $(ASTSPOOLDIR)" ; \
index 4135016..fb12e59 100644 (file)
@@ -2301,6 +2301,10 @@ static void ast_readconfig(void)
        char *config = AST_CONFIG_FILE;
        char hostname[MAXHOSTNAMELEN] = "";
        struct ast_flags config_flags = { 0 };
+       struct {
+               unsigned int dbdir:1;
+               unsigned int keydir:1;
+       } found = { 0, 0 };
 
        if (ast_opt_override_config) {
                cfg = ast_config_load(ast_config_AST_CONFIG_FILE, config_flags);
@@ -2348,10 +2352,18 @@ static void ast_readconfig(void)
                        snprintf(ast_config_AST_MONITOR_DIR, sizeof(ast_config_AST_MONITOR_DIR) - 1, "%s/monitor", v->value);
                } else if (!strcasecmp(v->name, "astvarlibdir")) {
                        ast_copy_string(ast_config_AST_VAR_DIR, v->value, sizeof(ast_config_AST_VAR_DIR));
+                       if (!found.dbdir)
+                               snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
+               } else if (!strcasecmp(v->name, "astdbdir")) {
                        snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
+                       found.dbdir = 1;
                } else if (!strcasecmp(v->name, "astdatadir")) {
                        ast_copy_string(ast_config_AST_DATA_DIR, v->value, sizeof(ast_config_AST_DATA_DIR));
+                       if (!found.keydir)
+                               snprintf(ast_config_AST_KEY_DIR, sizeof(ast_config_AST_KEY_DIR), "%s/keys", v->value);
+               } else if (!strcasecmp(v->name, "astkeydir")) {
                        snprintf(ast_config_AST_KEY_DIR, sizeof(ast_config_AST_KEY_DIR), "%s/keys", v->value);
+                       found.keydir = 1;
                } else if (!strcasecmp(v->name, "astlogdir")) {
                        ast_copy_string(ast_config_AST_LOG_DIR, v->value, sizeof(ast_config_AST_LOG_DIR));
                } else if (!strcasecmp(v->name, "astagidir")) {