We are shaking up trunk tonight! allow data dir to be specified (issue #6967 reported...
authorJoshua Colp <jcolp@digium.com>
Sat, 15 Apr 2006 22:53:53 +0000 (22:53 +0000)
committerJoshua Colp <jcolp@digium.com>
Sat, 15 Apr 2006 22:53:53 +0000 (22:53 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20330 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
app.c
asterisk.c
build_tools/make_defaults_h
file.c
http.c
image.c
include/asterisk.h
res/res_agi.c

index ff9d077..4498524 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -167,12 +167,13 @@ else
   ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
 endif
 endif
+ASTDATADIR?=$(ASTVARLIBDIR)
 
 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
 # when starting Asterisk
 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
 MODULES_DIR=$(ASTLIBDIR)/modules
-AGI_DIR=$(ASTVARLIBDIR)/agi-bin
+AGI_DIR=$(ASTDATADIR)/agi-bin
 
 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
 HTTP_DOCSDIR=/var/www/html
@@ -566,42 +567,42 @@ datafiles: all
        # Should static HTTP be installed during make samples or even with its own target ala
        # webvoicemail?  There are portions here that *could* be customized but might also be
        # improved a lot.  I'll put it here for now.
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/static-http
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
        for x in static-http/*; do \
-               install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/static-http ; \
+               install -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
        done
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/digits
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/priv-callerintros
        for x in sounds/digits/*.gsm; do \
                if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
+                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/digits ; \
                else \
                        echo "No description for $$x"; \
                        exit 1; \
                fi; \
        done
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/dictate
        for x in sounds/dictate/*.gsm; do \
                if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate ; \
+                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/dictate ; \
                else \
                        echo "No description for $$x"; \
                        exit 1; \
                fi; \
        done
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/letters
        for x in sounds/letters/*.gsm; do \
                if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
+                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/letters ; \
                else \
                        echo "No description for $$x"; \
                        exit 1; \
                fi; \
        done
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/phonetic
        for x in sounds/phonetic/*.gsm; do \
                if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
+                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/phonetic ; \
                else \
                        echo "No description for $$x"; \
                        exit 1; \
@@ -609,16 +610,16 @@ datafiles: all
        done
        for x in sounds/demo-* sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-* sounds/spy-* sounds/priv-* sounds/screen-* sounds/hello-*; do \
                if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
                else \
                        echo "No description for $$x"; \
                        exit 1; \
                fi; \
        done
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/images
        for x in images/*.jpg; do \
-               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
+               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
        done
        mkdir -p $(DESTDIR)$(AGI_DIR)
 
@@ -678,7 +679,7 @@ bininstall: all
        if [ -n "$(OLDHEADERS)" ]; then \
                rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
        fi
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds
        mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
        mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
        mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
@@ -779,6 +780,7 @@ samples: adsi
                echo "astetcdir => $(ASTETCDIR)" ; \
                echo "astmoddir => $(MODULES_DIR)" ; \
                echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
+               echo "astdatadir => $(ASTDATADIR)" ; \
                echo "astagidir => $(AGI_DIR)" ; \
                echo "astspooldir => $(ASTSPOOLDIR)" ; \
                echo "astrundir => $(ASTVARRUNDIR)" ; \
@@ -796,28 +798,28 @@ samples: adsi
        else \
                echo "Skipping asterisk.conf creation"; \
        fi
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds ; \
        for x in sounds/demo-*; do \
                if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+                       $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
                else \
                        echo "No description for $$x"; \
                        exit 1; \
                fi; \
        done
-       mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
+       mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
        for x in sounds/*.mp3; do \
-               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
+               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
        done
-       rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
+       rm -f $(DESTDIR)$(ASTDATADIR)/mohmp3/sample-hold.mp3
        mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
        :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
        for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
-               cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
+               cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
        done
        :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
        for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
-               cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
+               cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
        done
 
 webvmail:
@@ -939,7 +941,7 @@ _uninstall:
        rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
        rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
        rm -rf $(DESTDIR)$(ASTHEADERDIR)
-       rm -rf $(DESTDIR)$(ASTVARLIBDIR)/sounds
+       rm -rf $(DESTDIR)$(ASTDATADIR)/sounds
        rm -rf $(DESTDIR)$(ASTVARLIBDIR)/firmware
        rm -rf $(DESTDIR)$(ASTMANDIR)/man8
        for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
@@ -961,6 +963,7 @@ uninstall: _uninstall
 uninstall-all: _uninstall
        rm -rf $(DESTDIR)$(ASTLIBDIR)
        rm -rf $(DESTDIR)$(ASTVARLIBDIR)
+       rm -rf $(DESTDIR)$(ASTDATADIR)
        rm -rf $(DESTDIR)$(ASTSPOOLDIR)
        rm -rf $(DESTDIR)$(ASTETCDIR)
        rm -rf $(DESTDIR)$(ASTLOGDIR)
diff --git a/app.c b/app.c
index 34209a1..395c05c 100644 (file)
--- a/app.c
+++ b/app.c
@@ -414,7 +414,7 @@ int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, in
                if (filename[0] == '/') 
                        ast_copy_string(tmpf, filename, sizeof(tmpf));
                else
-                       snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_VAR_DIR, "sounds", filename);
+                       snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_DATA_DIR, "sounds", filename);
                fd = open(tmpf, O_RDONLY);
                if (fd < 0){
                        ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", tmpf, strerror(errno));
index ad9cfb8..9fd9674 100644 (file)
@@ -206,6 +206,7 @@ char ast_config_AST_MODULE_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_SPOOL_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_MONITOR_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH];
+char ast_config_AST_DATA_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_LOG_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_AGI_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_DB[AST_CONFIG_MAX_PATH];
@@ -2081,6 +2082,7 @@ static void ast_readconfig(void)
        ast_copy_string(ast_config_AST_MODULE_DIR, AST_MODULE_DIR, sizeof(ast_config_AST_MODULE_DIR));
        snprintf(ast_config_AST_MONITOR_DIR, sizeof(ast_config_AST_MONITOR_DIR) - 1, "%s/monitor", ast_config_AST_SPOOL_DIR);
        ast_copy_string(ast_config_AST_VAR_DIR, AST_VAR_DIR, sizeof(ast_config_AST_VAR_DIR));
+       ast_copy_string(ast_config_AST_DATA_DIR, AST_DATA_DIR, sizeof(ast_config_AST_DATA_DIR));
        ast_copy_string(ast_config_AST_LOG_DIR, AST_LOG_DIR, sizeof(ast_config_AST_LOG_DIR));
        ast_copy_string(ast_config_AST_AGI_DIR, AST_AGI_DIR, sizeof(ast_config_AST_AGI_DIR));
        ast_copy_string(ast_config_AST_DB, AST_DB, sizeof(ast_config_AST_DB));
@@ -2117,6 +2119,8 @@ static void ast_readconfig(void)
                        ast_copy_string(ast_config_AST_VAR_DIR, v->value, sizeof(ast_config_AST_VAR_DIR));
                        snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
                        snprintf(ast_config_AST_KEY_DIR, sizeof(ast_config_AST_KEY_DIR), "%s/keys", v->value);
+               } else if (!strcasecmp(v->name, "astdatadir")) {
+                       ast_copy_string(ast_config_AST_DATA_DIR, v->value, sizeof(ast_config_AST_DATA_DIR));
                } 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")) {
index 7b94111..f6559f2 100755 (executable)
@@ -11,6 +11,7 @@ cat << END
 #define AST_MODULE_DIR "${INSTALL_PATH}${MODULES_DIR}"
 #define AST_SPOOL_DIR  "${INSTALL_PATH}${ASTSPOOLDIR}"
 #define AST_VAR_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}"
+#define AST_DATA_DIR   "${INSTALL_PATH}${ASTDATADIR}"
 #define AST_LOG_DIR    "${INSTALL_PATH}${ASTLOGDIR}"
 #define AST_AGI_DIR    "${INSTALL_PATH}${AGI_DIR}"
 #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
@@ -19,7 +20,7 @@ cat << END
 
 #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
 
-#define AST_SOUNDS     "${INSTALL_PATH}${ASTVARLIBDIR}/sounds"
-#define AST_IMAGES     "${INSTALL_PATH}${ASTVARLIBDIR}/images"
+#define AST_SOUNDS     "${INSTALL_PATH}${ASTDATADIR}/sounds"
+#define AST_IMAGES     "${INSTALL_PATH}${ASTDATADIR}/images"
 
 END
diff --git a/file.c b/file.c
index aba9081..5bbcce0 100644 (file)
--- a/file.c
+++ b/file.c
@@ -261,7 +261,7 @@ static char *build_filename(const char *filename, const char *ext)
                asprintf(&fn, "%s.%s", filename, ext);
        else
                asprintf(&fn, "%s/sounds/%s.%s",
-                       ast_config_AST_VAR_DIR, filename, ext);
+                       ast_config_AST_DATA_DIR, filename, ext);
        return fn;
 }
 
diff --git a/http.c b/http.c
index 97eb676..736dfbd 100644 (file)
--- a/http.c
+++ b/http.c
@@ -125,12 +125,12 @@ static char *static_callback(struct sockaddr_in *req, const char *uri, struct as
        mtype=ftype2mtype(ftype, wkspace, sizeof(wkspace));
        
        /* Cap maximum length */
-       len = strlen(uri) + strlen(ast_config_AST_VAR_DIR) + strlen("/static-http/") + 5;
+       len = strlen(uri) + strlen(ast_config_AST_DATA_DIR) + strlen("/static-http/") + 5;
        if (len > 1024)
                goto out403;
                
        path = alloca(len);
-       sprintf(path, "%s/static-http/%s", ast_config_AST_VAR_DIR, uri);
+       sprintf(path, "%s/static-http/%s", ast_config_AST_DATA_DIR, uri);
        if (stat(path, &st))
                goto out404;
        if (S_ISDIR(st.st_mode))
diff --git a/image.c b/image.c
index 2e039fc..9d8901a 100644 (file)
--- a/image.c
+++ b/image.c
@@ -103,9 +103,9 @@ static void make_filename(char *buf, int len, char *filename, const char *prefla
                        snprintf(buf, len, "%s.%s", filename, ext);
        } else {
                if (!ast_strlen_zero(preflang))
-                       snprintf(buf, len, "%s/%s/%s-%s.%s", ast_config_AST_VAR_DIR, "images", filename, preflang, ext);
+                       snprintf(buf, len, "%s/%s/%s-%s.%s", ast_config_AST_DATA_DIR, "images", filename, preflang, ext);
                else
-                       snprintf(buf, len, "%s/%s/%s.%s", ast_config_AST_VAR_DIR, "images", filename, ext);
+                       snprintf(buf, len, "%s/%s/%s.%s", ast_config_AST_DATA_DIR, "images", filename, ext);
        }
 }
 
index 8e86832..b4546cf 100644 (file)
@@ -34,6 +34,7 @@ extern char ast_config_AST_MODULE_DIR[AST_CONFIG_MAX_PATH];
 extern char ast_config_AST_SPOOL_DIR[AST_CONFIG_MAX_PATH];
 extern char ast_config_AST_MONITOR_DIR[AST_CONFIG_MAX_PATH];
 extern char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH];
+extern char ast_config_AST_DATA_DIR[AST_CONFIG_MAX_PATH];
 extern char ast_config_AST_LOG_DIR[AST_CONFIG_MAX_PATH];
 extern char ast_config_AST_AGI_DIR[AST_CONFIG_MAX_PATH];
 extern char ast_config_AST_DB[AST_CONFIG_MAX_PATH];
index c007157..c7ff91c 100644 (file)
@@ -281,6 +281,7 @@ static int launch_script(char *script, char *argv[], int *fds, int *efd, int *op
                setenv("AST_SPOOL_DIR", ast_config_AST_SPOOL_DIR, 1);
                setenv("AST_MONITOR_DIR", ast_config_AST_MONITOR_DIR, 1);
                setenv("AST_VAR_DIR", ast_config_AST_VAR_DIR, 1);
+               setenv("AST_DATA_DIR", ast_config_AST_DATA_DIR, 1);
                setenv("AST_LOG_DIR", ast_config_AST_LOG_DIR, 1);
                setenv("AST_AGI_DIR", ast_config_AST_AGI_DIR, 1);
                setenv("AST_KEY_DIR", ast_config_AST_KEY_DIR, 1);