mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-22 09:37:04 +00:00
add -base option to modify the base directory
This commit is contained in:
parent
4aac01cfc4
commit
5a49352a0b
19
src/switch.c
19
src/switch.c
@ -48,7 +48,7 @@
|
||||
#include "private/switch_core_pvt.h"
|
||||
|
||||
/* pid filename: Stores the process id of the freeswitch process */
|
||||
#define PIDFILE "freeswitch.pid"
|
||||
#define PIDFILE "sangoma-media-gateway.pid"
|
||||
static char *pfile = PIDFILE;
|
||||
|
||||
|
||||
@ -346,6 +346,7 @@ int main(int argc, char *argv[])
|
||||
"\t-stop -- stop freeswitch\n"
|
||||
"\t-nc -- do not output to a console and background\n"
|
||||
"\t-c -- output to a console and stay in the foreground\n"
|
||||
"\t-base [basedir] -- specify an alternate base dir\n"
|
||||
"\t-conf [confdir] -- specify an alternate config dir\n"
|
||||
"\t-log [logdir] -- specify an alternate log dir\n"
|
||||
"\t-run [rundir] -- specify an alternate run dir\n"
|
||||
@ -578,6 +579,22 @@ int main(int argc, char *argv[])
|
||||
known_opt++;
|
||||
}
|
||||
|
||||
if (local_argv[x] && !strcmp(local_argv[x], "-base")) {
|
||||
x++;
|
||||
if (local_argv[x] && strlen(local_argv[x])) {
|
||||
SWITCH_GLOBAL_dirs.base_dir = (char *) malloc(strlen(local_argv[x]) + 1);
|
||||
if (!SWITCH_GLOBAL_dirs.base_dir) {
|
||||
fprintf(stderr, "Allocation error\n");
|
||||
return 255;
|
||||
}
|
||||
strcpy(SWITCH_GLOBAL_dirs.base_dir, local_argv[x]);
|
||||
} else {
|
||||
fprintf(stderr, "When using -base you must specify a base directory\n");
|
||||
return 255;
|
||||
}
|
||||
known_opt++;
|
||||
}
|
||||
|
||||
if (local_argv[x] && !strcmp(local_argv[x], "-log")) {
|
||||
x++;
|
||||
if (local_argv[x] && strlen(local_argv[x])) {
|
||||
|
@ -447,6 +447,9 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
|
||||
base_dir[(lastbacklash - base_dir)] = '\0';
|
||||
#else
|
||||
char base_dir[1024] = SWITCH_PREFIX_DIR;
|
||||
if (SWITCH_GLOBAL_dirs.base_dir) {
|
||||
snprintf(base_dir, sizeof(base_dir), "%s", SWITCH_GLOBAL_dirs.base_dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!SWITCH_GLOBAL_dirs.base_dir && (SWITCH_GLOBAL_dirs.base_dir = (char *) malloc(BUFSIZE))) {
|
||||
@ -1296,6 +1299,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
||||
switch_find_local_ip(guess_ip, sizeof(guess_ip), NULL, AF_INET6);
|
||||
switch_core_set_variable("local_ip_v6", guess_ip);
|
||||
switch_core_set_variable("base_dir", SWITCH_GLOBAL_dirs.base_dir);
|
||||
switch_core_set_variable("base_logdir", SWITCH_GLOBAL_dirs.log_dir);
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user