Introduce astcachedir, to be used for temporary bucket files
As described in the issue, /tmp is not a suitable location for a large amount of cached media files, since most distributions make /tmp a RAM-based tmpfs mount with limited capacity. I opted for a location that can be configured separately, as opposed to using a subdirectory of spooldir, given the different storage profile (transient files vs files that might stay there indefinitely). This commit just makes the cache directory configurable, but leaves it at /tmp by default, to ensure backwards compatibility. A future commit that only targets master could change the default location to something more sensible such as /var/tmp/asterisk. At that point, the cachedir could be created and cleaned up during uninstall by the Makefile script. ASTERISK-29143 Change-Id: Ic54e95199405abacd9e509cef5f08fa14c510b5d
This commit is contained in:
parent
ea744ca7c2
commit
8d2558209b
6
Makefile
6
Makefile
|
@ -49,6 +49,7 @@ DESTDIR?=$(INSTALL_PATH)
|
|||
export DESTDIR
|
||||
|
||||
export INSTALL_PATH # Additional prefix for the following paths
|
||||
export ASTCACHEDIR
|
||||
export ASTETCDIR # Path for config files
|
||||
export ASTVARRUNDIR
|
||||
export ASTSPOOLDIR
|
||||
|
@ -555,7 +556,7 @@ update:
|
|||
|
||||
NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
|
||||
OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
|
||||
INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
|
||||
INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTCACHEDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
|
||||
"$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
|
||||
"$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
|
||||
"$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
|
||||
|
@ -779,7 +780,8 @@ define INSTALL_CONFIGS
|
|||
done ; \
|
||||
if [ "$(OVERWRITE)" = "y" ]; then \
|
||||
echo "Updating asterisk.conf" ; \
|
||||
sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
|
||||
sed -e 's|^astcachedir.*$$|astcachedir => $(ASTCACHEDIR)|' \
|
||||
-e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
|
||||
-e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
|
||||
-e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
|
||||
-e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
|
||||
|
|
|
@ -26,6 +26,7 @@ trap cleanup_tmp 0
|
|||
src="$1"
|
||||
dst="$2"
|
||||
sed <"$src" \
|
||||
-e "s|__ASTERISK_CACHE_DIR__|$ASTCACHEDIR|g" \
|
||||
-e "s|__ASTERISK_DATA_DIR__|$ASTDATADIR|g" \
|
||||
-e "s|__ASTERISK_DB_DIR__|$ASTDBDIR|g" \
|
||||
-e "s|__ASTERISK_ETC_DIR__|$ASTETCDIR|g" \
|
||||
|
|
|
@ -7,6 +7,7 @@ cat << END
|
|||
*/
|
||||
#define DEFAULT_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
|
||||
|
||||
#define DEFAULT_CACHE_DIR "${INSTALL_PATH}${ASTCACHEDIR}"
|
||||
#define DEFAULT_CONFIG_DIR "${INSTALL_PATH}${ASTETCDIR}"
|
||||
#define DEFAULT_MODULE_DIR "${INSTALL_PATH}${ASTMODDIR}"
|
||||
#define DEFAULT_AGI_DIR "${INSTALL_PATH}${AGI_DIR}"
|
||||
|
|
|
@ -32,6 +32,7 @@ LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]
|
|||
cat <<EOF > "$PPATH/asterisk.pc"
|
||||
install_prefix=$INSTALL_PREFIX
|
||||
version_number=$ASTERISKVERSIONNUM
|
||||
cachedir=$ASTCACHEDIR
|
||||
etcdir=$ASTETCDIR
|
||||
libdir=$ASTLIBDIR
|
||||
varlibdir=$ASTVARLIBDIR
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[directories](!)
|
||||
astcachedir => /tmp
|
||||
astetcdir => /etc/asterisk
|
||||
astmoddir => /usr/lib/asterisk/modules
|
||||
astvarlibdir => /var/lib/asterisk
|
||||
|
|
|
@ -1287,6 +1287,7 @@ BUILD_OS
|
|||
BUILD_VENDOR
|
||||
BUILD_CPU
|
||||
BUILD_PLATFORM
|
||||
astcachedir
|
||||
astvarrundir
|
||||
astlogdir
|
||||
astspooldir
|
||||
|
@ -4652,6 +4653,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
|
|||
|
||||
# System default paths
|
||||
astsbindir='${sbindir}'
|
||||
astcachedir='/tmp'
|
||||
astetcdir='${sysconfdir}/asterisk'
|
||||
astheaderdir='${includedir}/asterisk'
|
||||
astlibdir='${libdir}'
|
||||
|
@ -4720,6 +4722,7 @@ $as_echo "#define _DARWIN_UNLIMITED_SELECT 1" >>confdefs.h
|
|||
;;
|
||||
solaris*)
|
||||
if test ${prefix} = 'NONE'; then
|
||||
astcachedir=/tmp
|
||||
astetcdir=/var/etc/asterisk
|
||||
astsbindir=/opt/asterisk/sbin
|
||||
astlibdir=/opt/asterisk/lib
|
||||
|
|
|
@ -34,6 +34,7 @@ AC_USE_SYSTEM_EXTENSIONS dnl note- does not work on FreeBSD
|
|||
|
||||
# System default paths
|
||||
AC_SUBST([astsbindir], ['${sbindir}'])dnl
|
||||
AC_SUBST([astcachedir], ['/tmp'])dnl
|
||||
AC_SUBST([astetcdir], ['${sysconfdir}/asterisk'])dnl
|
||||
AC_SUBST([astheaderdir], ['${includedir}/asterisk'])dnl
|
||||
AC_SUBST([astlibdir], ['${libdir}'])dnl
|
||||
|
@ -98,6 +99,7 @@ case "${host_os}" in
|
|||
;;
|
||||
solaris*)
|
||||
if test ${prefix} = 'NONE'; then
|
||||
astcachedir=/tmp
|
||||
astetcdir=/var/etc/asterisk
|
||||
astsbindir=/opt/asterisk/sbin
|
||||
astlibdir=/opt/asterisk/lib
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Subject: Core
|
||||
|
||||
The location where the media cache stores its temporary files
|
||||
is no longer hardcoded to /tmp but can now be configured separately
|
||||
via the astcachedir config variable in asterisk.conf. To retain
|
||||
backwards compatibility, the default location remains /tmp.
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef _ASTERISK_PATHS_H
|
||||
#define _ASTERISK_PATHS_H
|
||||
|
||||
extern const char *ast_config_AST_CACHE_DIR;
|
||||
extern const char *ast_config_AST_CONFIG_DIR;
|
||||
extern const char *ast_config_AST_CONFIG_FILE;
|
||||
extern const char *ast_config_AST_MODULE_DIR;
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "asterisk/json.h"
|
||||
#include "asterisk/file.h"
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/paths.h"
|
||||
|
||||
/*! \brief Number of buckets for the container of schemes */
|
||||
#define SCHEME_BUCKETS 53
|
||||
|
@ -899,7 +900,7 @@ int ast_bucket_file_temporary_create(struct ast_bucket_file *file)
|
|||
{
|
||||
int fd;
|
||||
|
||||
ast_copy_string(file->path, "/tmp/bucket-XXXXXX", sizeof(file->path));
|
||||
snprintf(file->path, sizeof(file->path), "%s/bucket-XXXXXX", ast_config_AST_CACHE_DIR);
|
||||
|
||||
fd = mkstemp(file->path);
|
||||
if (fd < 0) {
|
||||
|
|
|
@ -98,6 +98,7 @@ char record_cache_dir[AST_CACHE_DIR_LEN] = DEFAULT_TMP_DIR;
|
|||
char ast_defaultlanguage[MAX_LANGUAGE] = DEFAULT_LANGUAGE;
|
||||
|
||||
struct _cfg_paths {
|
||||
char cache_dir[PATH_MAX];
|
||||
char config_dir[PATH_MAX];
|
||||
char module_dir[PATH_MAX];
|
||||
char spool_dir[PATH_MAX];
|
||||
|
@ -125,6 +126,7 @@ struct _cfg_paths {
|
|||
};
|
||||
|
||||
static struct _cfg_paths cfg_paths = {
|
||||
.cache_dir = DEFAULT_CACHE_DIR,
|
||||
.config_dir = DEFAULT_CONFIG_DIR,
|
||||
.module_dir = DEFAULT_MODULE_DIR,
|
||||
.spool_dir = DEFAULT_SPOOL_DIR,
|
||||
|
@ -145,6 +147,7 @@ static struct _cfg_paths cfg_paths = {
|
|||
.ctl_file = "asterisk.ctl",
|
||||
};
|
||||
|
||||
const char *ast_config_AST_CACHE_DIR = cfg_paths.cache_dir;
|
||||
const char *ast_config_AST_CONFIG_DIR = cfg_paths.config_dir;
|
||||
const char *ast_config_AST_CONFIG_FILE = cfg_paths.config_file;
|
||||
const char *ast_config_AST_MODULE_DIR = cfg_paths.module_dir;
|
||||
|
@ -254,7 +257,9 @@ void load_asterisk_conf(void)
|
|||
}
|
||||
|
||||
for (v = ast_variable_browse(cfg, "directories"); v; v = v->next) {
|
||||
if (!strcasecmp(v->name, "astetcdir")) {
|
||||
if (!strcasecmp(v->name, "astcachedir")) {
|
||||
ast_copy_string(cfg_paths.cache_dir, v->value, sizeof(cfg_paths.cache_dir));
|
||||
} else if (!strcasecmp(v->name, "astetcdir")) {
|
||||
ast_copy_string(cfg_paths.config_dir, v->value, sizeof(cfg_paths.config_dir));
|
||||
} else if (!strcasecmp(v->name, "astspooldir")) {
|
||||
ast_copy_string(cfg_paths.spool_dir, v->value, sizeof(cfg_paths.spool_dir));
|
||||
|
|
|
@ -327,6 +327,8 @@ const char *ast_str_retrieve_variable(struct ast_str **str, ssize_t maxlen, stru
|
|||
s = ast_str_buffer(*str);
|
||||
} else if (!strcmp(var, "SYSTEMNAME")) {
|
||||
s = ast_config_AST_SYSTEM_NAME;
|
||||
} else if (!strcmp(var, "ASTCACHEDIR")) {
|
||||
s = ast_config_AST_CACHE_DIR;
|
||||
} else if (!strcmp(var, "ASTETCDIR")) {
|
||||
s = ast_config_AST_CONFIG_DIR;
|
||||
} else if (!strcmp(var, "ASTMODDIR")) {
|
||||
|
|
|
@ -97,6 +97,7 @@ ASTMODDIR = @astmoddir@
|
|||
ASTMANDIR = @astmandir@
|
||||
astvarlibdir = @astvarlibdir@
|
||||
ASTVARLIBDIR = @astvarlibdir@
|
||||
ASTCACHEDIR = @astcachedir@
|
||||
ASTDATADIR = @astdatadir@
|
||||
ASTDBDIR = @astdbdir@
|
||||
ASTKEYDIR = @astkeydir@
|
||||
|
|
Loading…
Reference in New Issue