]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add support for cache directory
authorRussell Treleaven <rtreleaven@bunnykick.ca>
Mon, 1 Sep 2014 00:22:08 +0000 (20:22 -0400)
committerRussell Treleaven <rtreleaven@bunnykick.ca>
Mon, 1 Sep 2014 00:22:08 +0000 (20:22 -0400)
make configs use specific directory variables instead of just base_dir
so that one configuration can be used for fhs and legacy installations

23 files changed:
conf/vanilla/autoload_configs/blacklist.conf.xml
conf/vanilla/autoload_configs/callcenter.conf.xml
conf/vanilla/autoload_configs/cdr_pg_csv.conf.xml
conf/vanilla/autoload_configs/erlang_event.conf.xml
conf/vanilla/autoload_configs/fax.conf.xml
conf/vanilla/autoload_configs/format_cdr.conf.xml
conf/vanilla/autoload_configs/httapi.conf.xml
conf/vanilla/autoload_configs/http_cache.conf.xml
conf/vanilla/autoload_configs/java.conf.xml
conf/vanilla/autoload_configs/lua.conf.xml
conf/vanilla/autoload_configs/perl.conf.xml
conf/vanilla/autoload_configs/spandsp.conf.xml
conf/vanilla/autoload_configs/verto.conf.xml
conf/vanilla/autoload_configs/voicemail.conf.xml
conf/vanilla/autoload_configs/xml_cdr.conf.xml
conf/vanilla/autoload_configs/xml_curl.conf.xml
conf/vanilla/dialplan/default.xml
conf/vanilla/sip_profiles/internal.xml
conf/vanilla/vars.xml
configure.ac
src/include/switch_types.h
src/switch.c
src/switch_core.c

index a981ebbdb0b0e8cf5fa2da651140ffa5e4efb343..9995febd8325d7e5f9fdfb4865ae306242c36564 100644 (file)
@@ -5,7 +5,7 @@
 
                NOTE: make sure the file exists and is readable by FreeSWITCH.
 
-       <list name="example" filename="/usr/local/freeswitch/conf/blacklists/example.list"/>
+       <list name="example" filename="$${conf_dir}/blacklists/example.list"/>
        -->
 </lists>
 </configuration>
index a069413ac6a072440a9faf8af522e08c8bc8eadc..fbc02c4a106008af7ab2ccce594e383618dd778a 100644 (file)
@@ -9,7 +9,7 @@
     <queue name="support@default">
       <param name="strategy" value="longest-idle-agent"/>
       <param name="moh-sound" value="$${hold_music}"/>
-      <!--<param name="record-template" value="$${base_dir}/recordings/${strftime(%Y-%m-%d-%H-%M-%S)}.${destination_number}.${caller_id_number}.${uuid}.wav"/>-->
+      <!--<param name="record-template" value="$${recordings_dir}/${strftime(%Y-%m-%d-%H-%M-%S)}.${destination_number}.${caller_id_number}.${uuid}.wav"/>-->
       <param name="time-base-score" value="system"/>
       <param name="max-wait-time" value="0"/>
       <param name="max-wait-time-with-no-agent" value="0"/>
index 4fec817b453a0a90dd4464e1f559c886257c669b..9891455f8adb87ed88e4361c35ee7ceb0fa2d304 100644 (file)
@@ -9,7 +9,7 @@
     <param name="legs" value="a"/>
 
     <!-- Directory in which to spool failed SQL inserts -->
-    <!-- <param name="spool-dir" value="$${base_dir}/log/cdr-pg-csv"/> -->
+    <!-- <param name="spool-dir" value="$${log_dir}/cdr-pg-csv"/> -->
     <!-- Disk spool format if DB connection/insert fails - csv (default) or sql -->
     <param name="spool-format" value="csv"/>
     <param name="rotate-on-hup" value="true"/>
index 62deb84f67a6f6e7ed55c1281016e3f1d312a58e..7f627668efcdcc610ab711c526a9351dfdecb052 100644 (file)
@@ -11,7 +11,7 @@
     <!-- Specify this OR 'cookie-file' or $HOME/.erlang.cookie will be read -->
     <param name="cookie" value="ClueCon"/>
     <!-- Read a cookie from an arbitary erlang cookie file instead -->
-    <!--<param name="cookie-file" value="/tmp/erlang.cookie"/>-->
+    <!--<param name="cookie-file" value="/$${temp_dir}/erlang.cookie"/>-->
     <param name="shortname" value="true"/>
     <!-- in additon to cookie, optionally restrict by ACL -->
     <!--<param name="apply-inbound-acl" value="lan"/>-->
index c7d825665ea82aca868f9521aa757512af5aedda..d6a5ff734b1c01472f9eea67ce2c5574b7a39b06 100644 (file)
@@ -6,7 +6,7 @@
        <param name="ident"             value="SpanDSP Fax Ident"/>
        <param name="header"            value="SpanDSP Fax Header"/>
 
-       <param name="spool-dir"         value="/tmp"/>
+       <param name="spool-dir"         value="$${temp_dir}"/>
        <param name="file-prefix"       value="faxrx"/>
     </settings>
 </configuration>
index 227bcb47222c8bec6433de43220f5cd8c4eaf36f..0c42e78b409ac3261b803f00c4deb996cf2d53f5 100644 (file)
@@ -46,7 +46,7 @@
     
     <!-- optional: full path to the error log dir for failed web posts if not specified its the same as log-dir -->
     <!-- either an absolute path, a relative path assuming ${prefix}/logs or a blank or omitted value will default to ${prefix}/logs/format_cdr -->
-    <!-- <param name="err-log-dir" value="/tmp"/> -->
+    <!-- <param name="err-log-dir" value="$${temp_dir}"/> -->
 
     <!-- which auhtentification scheme to use. Supported values are: basic, digest, NTLM, GSS-NEGOTIATE or "any" for automatic detection -->
     <!--<param name="auth-scheme" value="basic"/>--> 
          Specify your public key with 'ssl-cert-path' and the private key with
          'ssl-key-path'. If your private key has a password, specify it with
          'ssl-key-password'. -->
-    <!-- <param name="ssl-cert-path" value="$${base_dir}/conf/certs/public_key.pem"/> -->
-    <!-- <param name="ssl-key-path" value="$${base_dir}/conf/certs/private_key.pem"/> -->
+    <!-- <param name="ssl-cert-path" value="$${certs_dir}/public_key.pem"/> -->
+    <!-- <param name="ssl-key-path" value="$${certs_dir}/private_key.pem"/> -->
     <!-- <param name="ssl-key-password" value="MyPrivateKeyPassword"/> -->
 
     <!-- optional: use a custom CA certificate in PEM format to verify the peer
          with. This is useful if you are acting as your own certificate authority.
          note: only makes sense if used in combination with "enable-cacert-check." -->
-    <!-- <param name="ssl-cacert-file" value="$${base_dir}/conf/certs/cacert.pem"/> -->
+    <!-- <param name="ssl-cacert-file" value="$${certs_dir}/cacert.pem"/> -->
 
     <!-- optional: specify the SSL version to force HTTPS to use. Valid options are
          "SSLv3" and "TLSv1". Otherwise libcurl will auto-negotiate the version. -->
     <!-- <param name="ssl-version" value="TLSv1"/> -->
 
     <!-- optional: enables cookies and stores them in the specified file. -->
-    <!-- <param name="cookie-file" value="/tmp/cookie-mod_format_cdr_curl.txt"/> -->
+    <!-- <param name="cookie-file" value="/$${temp_dir}/cookie-mod_format_cdr_curl.txt"/> -->
 
     <!-- Whether to URL encode the individual JSON values. Defaults to true, set to false for standard JSON. -->
     <param name="encode-values" value="true"/>
index 50bbe78f409e6e44ef001d748d312b9f96fbf905..d0b357d0fe8025bffe1e6d45c79b4c1ba2aca521 100644 (file)
             Specify your public key with 'ssl-cert-path' and the private key with
             'ssl-key-path'. If your private key has a password, specify it with
             'ssl-key-password'. -->
-       <!-- <param name="ssl-cert-path" value="$${base_dir}/conf/certs/public_key.pem"/> -->
-       <!-- <param name="ssl-key-path" value="$${base_dir}/conf/certs/private_key.pem"/> -->
+       <!-- <param name="ssl-cert-path" value="$${certs_dir}/public_key.pem"/> -->
+       <!-- <param name="ssl-key-path" value="$${certs_dir}/private_key.pem"/> -->
        <!-- <param name="ssl-key-password" value="MyPrivateKeyPassword"/> -->
        <!-- optional timeout -->
        <!-- <param name="timeout" value="10"/> -->
        <!-- optional: use a custom CA certificate in PEM format to verify the peer
             with. This is useful if you are acting as your own certificate authority.
             note: only makes sense if used in combination with "enable-cacert-check." -->
-       <!-- <param name="ssl-cacert-file" value="$${base_dir}/conf/certs/cacert.pem"/> -->
+       <!-- <param name="ssl-cacert-file" value="$${certs_dir}/cacert.pem"/> -->
 
        <!-- optional: specify the SSL version to force HTTPS to use. Valid options are
             "SSLv3" and "TLSv1". Otherwise libcurl will auto-negotiate the version. -->
        <!-- <param name="ssl-version" value="TLSv1"/> -->
 
        <!-- optional: enables cookies and stores them in the specified file. -->
-       <!-- <param name="cookie-file" value="/tmp/cookie-mod_xml_curl.txt"/> -->
+       <!-- <param name="cookie-file" value="/$${temp_dir}/cookie-mod_xml_curl.txt"/> -->
 
        <!-- one or more of these imply you want to pick the exact variables that are transmitted -->
        <!--<param name="enable-post-var" value="Caller-Unique-ID"/>-->
index 5d0294c66227bbf6cb8a4bdefee137afeb0806c0..cd6ec119b43d86b3f388cb27841a7334c8424340 100644 (file)
@@ -3,12 +3,12 @@
     <!-- set to true if you want to enable http:// and https:// formats.  Do not use if mod_httapi is also loaded -->
     <param name="enable-file-formats" value="false"/>
     <param name="max-urls" value="10000"/>
-    <param name="location" value="$${base_dir}/http_cache"/>
+    <param name="location" value="$${cache_dir}"/>
     <param name="default-max-age" value="86400"/>
     <param name="prefetch-thread-count" value="8"/>
     <param name="prefetch-queue-size" value="100"/>
     <!-- absolute path to CA bundle file -->
-    <param name="ssl-cacert" value="$${base_dir}/conf/cacert.pem"/>
+    <param name="ssl-cacert" value="$${certs_dir}/cacert.pem"/>
     <!-- verify certificates -->
     <param name="ssl-verifypeer" value="true"/>
     <!-- verify host name matches certificate -->
index 5f71553e30f6085e1632ee3501eebca9b44964b8..1da38f487fce3fa553823b9c6aff4ac73607f4e3 100644 (file)
@@ -1,7 +1,7 @@
 <configuration name="java.conf" description="Java Plug-Ins">
   <javavm path="/opt/jdk1.6.0_04/jre/lib/amd64/server/libjvm.so"/>
   <options>
-    <option value="-Djava.class.path=$${base_dir}/scripts/freeswitch.jar:$${base_dir}/scripts/example.jar"/>
+    <option value="-Djava.class.path=$${script_dir}freeswitch.jar:$${script_dir}/example.jar"/>
     <option value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000"/>
   </options>
   <startup class="org/freeswitch/example/ApplicationLauncher" method="startup"/>
index f50307ea89ba6469d0d08bf2d8b9803e1214882b..fafd3361690f78fbb05b3be567bb67f42b97b009 100644 (file)
@@ -13,7 +13,7 @@
     These entries will be pre-pended to the LUA_PATH environment variable
     -->
     <!-- <param name="script-directory" value="/usr/local/lua/?.lua"/> -->
-    <!-- <param name="script-directory" value="$${base_dir}/scripts/?.lua"/> -->
+    <!-- <param name="script-directory" value="$${script_dir}/?.lua"/> -->
 
     <!--<param name="xml-handler-script" value="/dp.lua"/>-->
     <!--<param name="xml-handler-bindings" value="dialplan"/>-->
index b2435000ffa838e512e4aa48ac52b1307e0296fa..0249119230785f7ba391da0e29c2cd328e717b55 100644 (file)
@@ -1,6 +1,6 @@
 <configuration name="perl.conf" description="PERL Configuration">
   <settings>
-    <!--<param name="xml-handler-script" value="/tmp/xml.pl"/>-->
+    <!--<param name="xml-handler-script" value="$${temp_dir}/xml.pl"/>-->
     <!--<param name="xml-handler-bindings" value="dialplan"/>-->
 
     <!--
index 0241c1f4d151e24c91aef66bfa88fc4d3c0712b2..2653c40bb8a2c19781491df2f3863942e3d6990b 100644 (file)
@@ -32,7 +32,7 @@
        <param name="ident"             value="SpanDSP Fax Ident"/>
        <param name="header"            value="SpanDSP Fax Header"/>
 
-       <param name="spool-dir"         value="/tmp"/>
+       <param name="spool-dir"         value="$${temp_dir}"/>
        <param name="file-prefix"       value="faxrx"/>
     </fax-settings>
 
index bc61c816554b576bf741ec48dc9137e0c2c718de..34623ba27772261ea28b953e9095fad42cd09549 100644 (file)
@@ -8,8 +8,8 @@
     <profile name="mine">
       <param name="bind-local" value="0.0.0.0:8081"/>
       <param name="bind-local" value="0.0.0.0:8082" secure="true"/>
-      <param name="secure-combined" value="$${base_dir}/certs/wss.pem"/>
-      <param name="secure-chain" value="$${base_dir}/certs/wss.pem"/>
+      <param name="secure-combined" value="$${certs_dir}/wss.pem"/>
+      <param name="secure-chain" value="$${certs_dir}/wss.pem"/>
       <param name="userauth" value="true"/>
       <!-- setting this to true will allow anyone to register even with no account so use with care -->
       <param name="blind-reg" value="false"/>
index 9e5e67ffa343916973be84c95445398adc3fb6a3..8052d611f1b0dd4f5860505fdc1f5fd1573eeffe 100644 (file)
@@ -64,7 +64,7 @@
         <param name="date-fmt" value="%A, %B %d %Y, %I %M %p"/>
         <param name="email-from" value="${voicemail_account}@${voicemail_domain}"/>
       </email>
-      <!--<param name="storage-dir" value="/tmp"/>-->
+      <!--<param name="storage-dir" value="$${storage}"/>-->
       <!--<param name="odbc-dsn" value="dsn:user:pass"/>-->
       <!--<param name="record-comment" value="Your Comment"/>-->
       <!--<param name="record-title" value="Your Title"/>-->
index ac9b1f94d30fdfebe55c3b32f8c1a89cfcc89562..d4c4bea8d95dda76581b4fbd9e05f66d985ad977 100644 (file)
@@ -35,7 +35,7 @@
     
     <!-- optional: full path to the error log dir for failed web posts if not specified its the same as log-dir -->
     <!-- either an absolute path, a relative path assuming ${prefix}/logs or a blank or omitted value will default to ${prefix}/logs/xml_cdr -->
-    <!-- <param name="err-log-dir" value="/tmp"/> -->
+    <!-- <param name="err-log-dir" value="$${temp_dir}"/> -->
 
     <!-- which auhtentification scheme to use. Supported values are: basic, digest, NTLM, GSS-NEGOTIATE or "any" for automatic detection -->
     <!--<param name="auth-scheme" value="basic"/>--> 
          Specify your public key with 'ssl-cert-path' and the private key with
          'ssl-key-path'. If your private key has a password, specify it with
          'ssl-key-password'. -->
-    <!-- <param name="ssl-cert-path" value="$${base_dir}/conf/certs/public_key.pem"/> -->
-    <!-- <param name="ssl-key-path" value="$${base_dir}/conf/certs/private_key.pem"/> -->
+    <!-- <param name="ssl-cert-path" value="$${certs_dir}/public_key.pem"/> -->
+    <!-- <param name="ssl-key-path" value="$${certs_dir}/private_key.pem"/> -->
     <!-- <param name="ssl-key-password" value="MyPrivateKeyPassword"/> -->
 
     <!-- optional: use a custom CA certificate in PEM format to verify the peer
          with. This is useful if you are acting as your own certificate authority.
          note: only makes sense if used in combination with "enable-cacert-check." -->
-    <!-- <param name="ssl-cacert-file" value="$${base_dir}/conf/certs/cacert.pem"/> -->
+    <!-- <param name="ssl-cacert-file" value="$${certs_dir}/cacert.pem"/> -->
 
     <!-- optional: specify the SSL version to force HTTPS to use. Valid options are
          "SSLv3" and "TLSv1". Otherwise libcurl will auto-negotiate the version. -->
     <!-- <param name="ssl-version" value="TLSv1"/> -->
 
     <!-- optional: enables cookies and stores them in the specified file. -->
-    <!-- <param name="cookie-file" value="/tmp/cookie-mod_xml_curl.txt"/> -->
+    <!-- <param name="cookie-file" value="/$${temp_dir}/cookie-mod_xml_curl.txt"/> -->
   </settings>
 </configuration>
index 30951d83c83f28cb870e1ecafe99bf88b97e6ce8..de0de0293ae96a51f57664e9bf78d0d225e13e43 100644 (file)
@@ -24,8 +24,8 @@
            Specify your public key with 'ssl-cert-path' and the private key with
            'ssl-key-path'. If your private key has a password, specify it with
            'ssl-key-password'. -->
-      <!-- <param name="ssl-cert-path" value="$${base_dir}/conf/certs/public_key.pem"/> -->
-      <!-- <param name="ssl-key-path" value="$${base_dir}/conf/certs/private_key.pem"/> -->
+      <!-- <param name="ssl-cert-path" value="$${certs_dir}/public_key.pem"/> -->
+      <!-- <param name="ssl-key-path" value="$${certs_dir}/private_key.pem"/> -->
       <!-- <param name="ssl-key-password" value="MyPrivateKeyPassword"/> -->
       <!-- optional timeout -->
       <!-- <param name="timeout" value="10"/> -->
       <!-- optional: use a custom CA certificate in PEM format to verify the peer
            with. This is useful if you are acting as your own certificate authority.
            note: only makes sense if used in combination with "enable-cacert-check." -->
-      <!-- <param name="ssl-cacert-file" value="$${base_dir}/conf/certs/cacert.pem"/> -->
+      <!-- <param name="ssl-cacert-file" value="$${certs_dir}/cacert.pem"/> -->
 
       <!-- optional: specify the SSL version to force HTTPS to use. Valid options are
            "SSLv3" and "TLSv1". Otherwise libcurl will auto-negotiate the version. -->
       <!-- <param name="ssl-version" value="TLSv1"/> -->
 
       <!-- optional: enables cookies and stores them in the specified file. -->
-      <!-- <param name="cookie-file" value="/tmp/cookie-mod_xml_curl.txt"/> -->
+      <!-- <param name="cookie-file" value="/$${temp_dir}/cookie-mod_xml_curl.txt"/> -->
 
       <!-- one or more of these imply you want to pick the exact variables that are transmitted -->
       <!--<param name="enable-post-var" value="Unique-ID"/>-->
index 8c4a1f0312f8803cebdc8429d4453ff7e16290fe..8971939ec25ebfa303ac7f38ae529f0d588f37f6 100644 (file)
 
       <condition field="${default_password}" expression="^1234$" break="never">
        <action application="log" data="CRIT WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING "/>
-       <action application="log" data="CRIT Open ${base_dir}/conf/vars.xml and change the default_password."/>
+       <action application="log" data="CRIT Open $${conf_dir}/vars.xml and change the default_password."/>
        <action application="log" data="CRIT Once changed type 'reloadxml' at the console."/>
        <action application="log" data="CRIT WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING "/>
        <action application="sleep" data="10000"/>
       <condition field="destination_number" expression="^9178$">
        <action application="answer" />
        <action application="playback" data="silence_stream://2000"/>
-       <action application="rxfax" data="/tmp/rxfax.tif"/>
+       <action application="rxfax" data="$${temp_dir}/rxfax.tif"/>
        <action application="hangup"/>
       </condition>
     </extension>
 
     <extension name="fax_transmit">
       <condition field="destination_number" expression="^9179$">
-       <action application="txfax" data="/tmp/txfax.tif"/>
+       <action application="txfax" data="$${temp_dir}/txfax.tif"/>
        <action application="hangup"/>
       </condition>
     </extension>
     <extension name="video_record">
       <condition field="destination_number" expression="^9193$">
        <action application="answer"/>
-       <action application="record_fsv" data="/tmp/testrecord.fsv"/>
+       <action application="record_fsv" data="$${temp_dir}/testrecord.fsv"/>
       </condition>
     </extension>
 
     <extension name="video_playback">
       <condition field="destination_number" expression="^9194$">
        <action application="answer"/>
-       <action application="play_fsv" data="/tmp/testrecord.fsv"/>
+       <action application="play_fsv" data="$${temp_dir}/testrecord.fsv"/>
       </condition>
     </extension>
 
     <extension name="tone_stream">
       <condition field="destination_number" expression="^9198$">
        <action application="answer"/>
-       <action application="playback" data="{loops=10}tone_stream://path=${base_dir}/conf/tetris.ttml"/>
+       <action application="playback" data="{loops=10}tone_stream://path=${conf_dir}/tetris.ttml"/>
       </condition>
     </extension>
 
index 583db26db33b57c54bf2e4fa890b1d5716c54015..9e6a93ae2a2f017ec0f6eddb2e700af194afd949 100644 (file)
     <!--<param name="ws-binding"  value=":5066"/>-->
 
     <!-- uncomment for sip over secure websocket support -->
-    <!-- You need wss.pem in /usr/local/freeswitch/certs for wss -->
+    <!-- You need wss.pem in $${certs_dir} for wss -->
     <!--<param name="wss-binding" value=":7443"/>-->
     
 
index 20016cd85f8baecd2e39c8a37a0d531693cdb030..0b161854fff1620b078a5acffe8218424f964ef0 100644 (file)
       recordings_dir
       sound_prefix
       sounds_dir
+      conf_dir
+      log_dir
+      run_dir
+      db_dir
+      mod_dir
+      htdocs_dir
+      script_dir
+      temp_dir
+      grammar_dir
+      certs_dir
+      storage
+      cache_dir
       core_uuid
       zrtp_enabled
       nat_public_addr
           false     - implies forbidden
           true      - implies mandatory
 
-         default if not set is accept SAVP inbound if offered.
+      default if not set is accept SAVP inbound if offered.
 
 
       rtp_secure_media_inbound | rtp_secure_media_outbound
index 8b0a47e478544cfab2735ad4b4193e8abee591e8..02b5e7159c26f88386a733be728dc3e1a7947af2 100644 (file)
@@ -84,6 +84,7 @@ default_runtimedir="$rundir"
 default_scriptdir="$prefix/scripts"
 default_soundsdir="$prefix/sounds"
 default_storagedir="$prefix/storage"
+default_cachedir="$prefix/cache"
 
 if test "$enable_fhs" = yes; then
   prefix="/usr" exec_prefix="$prefix"
@@ -102,6 +103,7 @@ if test "$enable_fhs" = yes; then
   default_scriptdir="/usr/share/freeswitch/scripts"
   default_soundsdir="/usr/share/freeswitch/sounds"
   default_storagedir="/var/lib/freeswitch/storage"
+  default_cachedir="/var/cache/freeswitch"
 fi
 
 # Where to install the modules
@@ -161,6 +163,11 @@ AC_ARG_WITH([storagedir],
 AC_SUBST(storagedir)
 AC_DEFINE_UNQUOTED([SWITCH_STORAGE_DIR],"${storagedir}",[where to put storage files])
 
+AC_ARG_WITH([cachedir],
+       [AS_HELP_STRING([--with-cachedir=DIR], [Put cache files into this location (default: $prefix/cache)])], [cachedir="$withval"], [cachedir="${default_cachedir}"])
+AC_SUBST(cachedir)
+AC_DEFINE_UNQUOTED([SWITCH_CACHE_DIR],"${cachedir}",[where to put cache files])
+
 if test "$sysconfdir" = "\${prefix}/etc" ; then
     confdir="$prefix/conf"
 else
@@ -1748,5 +1755,6 @@ echo "      runtimedir:      ${runtimedir}"
 echo "      scriptdir:       ${scriptdir}"
 echo "      soundsdir:       ${soundsdir}"
 echo "      storagedir:      ${storagedir}"
+echo "      cachedir:        ${cachedir}"
 echo ""
 echo "------------------------------------------------------------------------------"
index 55f1bd16148bc0508d895c5b325c3949c368d423..988cd13e633bcf96814f1dda4c3a71bdf331e69e 100644 (file)
@@ -510,6 +510,7 @@ struct switch_directories {
        char *htdocs_dir;
        char *grammar_dir;
        char *storage_dir;
+       char *cache_dir;
        char *recordings_dir;
        char *sounds_dir;
        char *lib_dir;
index c0d3a84f7a3d4ab9eadae2fe049525ed32351eb5..2433535152e966a608934376b37998b04e6fdad3 100644 (file)
@@ -478,6 +478,7 @@ static const char usage[] =
        "\t-certs [directory]      -- alternate directory for certificates\n"
        "\t-recordings [directory] -- alternate directory for recordings\n"
        "\t-storage [directory]    -- alternate directory for voicemail storage\n"
+       "\t-cache [directory]      -- alternate directory for cache files\n"
        "\t-sounds [directory]     -- alternate directory for sound files\n";
 
 
@@ -929,6 +930,21 @@ int main(int argc, char *argv[])
                        strcpy(SWITCH_GLOBAL_dirs.storage_dir, local_argv[x]);
                }
 
+               else if (!strcmp(local_argv[x], "-cache")) {
+                       x++;
+                       if (switch_strlen_zero(local_argv[x]) || is_option(local_argv[x])) {
+                               fprintf(stderr, "When using -cache you must specify a cache directory\n");
+                               return 255;
+                       }
+
+                       SWITCH_GLOBAL_dirs.cache_dir = (char *) malloc(strlen(local_argv[x]) + 1);
+                       if (!SWITCH_GLOBAL_dirs.cache_dir) {
+                               fprintf(stderr, "Allocation error\n");
+                               return 255;
+                       }
+                       strcpy(SWITCH_GLOBAL_dirs.cache_dir, local_argv[x]);
+               }
+
                else if (!strcmp(local_argv[x], "-recordings")) {
                        x++;
                        if (switch_strlen_zero(local_argv[x]) || is_option(local_argv[x])) {
index b2b05e8b7a2cf107b5564197f0ac5a5c2d6684d0..7d5af36c281febda4640ad437294a038ded54017 100644 (file)
@@ -726,6 +726,17 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
 #endif
        }
 
+       if (!SWITCH_GLOBAL_dirs.cache_dir && (SWITCH_GLOBAL_dirs.cache_dir = (char *) malloc(BUFSIZE))) {
+               if (SWITCH_GLOBAL_dirs.base_dir)
+                       switch_snprintf(SWITCH_GLOBAL_dirs.cache_dir, BUFSIZE, "%s%scache", SWITCH_GLOBAL_dirs.base_dir, SWITCH_PATH_SEPARATOR);
+               else
+#ifdef SWITCH_CACHE_DIR
+                       switch_snprintf(SWITCH_GLOBAL_dirs.cache_dir, BUFSIZE, "%s", SWITCH_CACHE_DIR);
+#else
+                       switch_snprintf(SWITCH_GLOBAL_dirs.cache_dir, BUFSIZE, "%s%scache", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
+       }
+
        if (!SWITCH_GLOBAL_dirs.db_dir && (SWITCH_GLOBAL_dirs.db_dir = (char *) malloc(BUFSIZE))) {
                if (SWITCH_GLOBAL_dirs.base_dir)
                        switch_snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, "%s%sdb", SWITCH_GLOBAL_dirs.base_dir, SWITCH_PATH_SEPARATOR);
@@ -1717,6 +1728,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
        switch_core_set_variable("recordings_dir", SWITCH_GLOBAL_dirs.recordings_dir);
        switch_core_set_variable("sound_prefix", SWITCH_GLOBAL_dirs.sounds_dir);
        switch_core_set_variable("sounds_dir", SWITCH_GLOBAL_dirs.sounds_dir);
+       switch_core_set_variable("conf_dir", SWITCH_GLOBAL_dirs.conf_dir);
+       switch_core_set_variable("log_dir", SWITCH_GLOBAL_dirs.log_dir);
+       switch_core_set_variable("run_dir", SWITCH_GLOBAL_dirs.run_dir);
+       switch_core_set_variable("db_dir", SWITCH_GLOBAL_dirs.db_dir);
+       switch_core_set_variable("mod_dir", SWITCH_GLOBAL_dirs.mod_dir);
+       switch_core_set_variable("htdocs_dir", SWITCH_GLOBAL_dirs.htdocs_dir);
+       switch_core_set_variable("script_dir", SWITCH_GLOBAL_dirs.script_dir);
+       switch_core_set_variable("temp_dir", SWITCH_GLOBAL_dirs.temp_dir);
+       switch_core_set_variable("grammar_dir", SWITCH_GLOBAL_dirs.grammar_dir);
+       switch_core_set_variable("certs_dir", SWITCH_GLOBAL_dirs.certs_dir);
+       switch_core_set_variable("storage", SWITCH_GLOBAL_dirs.storage_dir);
+       switch_core_set_variable("cache_dir", SWITCH_GLOBAL_dirs.cache_dir);
        switch_core_set_serial();
 
        switch_console_init(runtime.memory_pool);
@@ -2702,6 +2725,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
        switch_safe_free(SWITCH_GLOBAL_dirs.htdocs_dir);
        switch_safe_free(SWITCH_GLOBAL_dirs.grammar_dir);
        switch_safe_free(SWITCH_GLOBAL_dirs.storage_dir);
+       switch_safe_free(SWITCH_GLOBAL_dirs.cache_dir);
        switch_safe_free(SWITCH_GLOBAL_dirs.recordings_dir);
        switch_safe_free(SWITCH_GLOBAL_dirs.sounds_dir);
        switch_safe_free(SWITCH_GLOBAL_dirs.run_dir);