mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
add -base option to modify the base directory
This commit is contained in:
19
src/switch.c
19
src/switch.c
@@ -48,7 +48,7 @@
|
|||||||
#include "private/switch_core_pvt.h"
|
#include "private/switch_core_pvt.h"
|
||||||
|
|
||||||
/* pid filename: Stores the process id of the freeswitch process */
|
/* pid filename: Stores the process id of the freeswitch process */
|
||||||
#define PIDFILE "freeswitch.pid"
|
#define PIDFILE "sangoma-media-gateway.pid"
|
||||||
static char *pfile = PIDFILE;
|
static char *pfile = PIDFILE;
|
||||||
|
|
||||||
|
|
||||||
@@ -346,6 +346,7 @@ int main(int argc, char *argv[])
|
|||||||
"\t-stop -- stop freeswitch\n"
|
"\t-stop -- stop freeswitch\n"
|
||||||
"\t-nc -- do not output to a console and background\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-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-conf [confdir] -- specify an alternate config dir\n"
|
||||||
"\t-log [logdir] -- specify an alternate log dir\n"
|
"\t-log [logdir] -- specify an alternate log dir\n"
|
||||||
"\t-run [rundir] -- specify an alternate run dir\n"
|
"\t-run [rundir] -- specify an alternate run dir\n"
|
||||||
@@ -578,6 +579,22 @@ int main(int argc, char *argv[])
|
|||||||
known_opt++;
|
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")) {
|
if (local_argv[x] && !strcmp(local_argv[x], "-log")) {
|
||||||
x++;
|
x++;
|
||||||
if (local_argv[x] && strlen(local_argv[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';
|
base_dir[(lastbacklash - base_dir)] = '\0';
|
||||||
#else
|
#else
|
||||||
char base_dir[1024] = SWITCH_PREFIX_DIR;
|
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
|
#endif
|
||||||
|
|
||||||
if (!SWITCH_GLOBAL_dirs.base_dir && (SWITCH_GLOBAL_dirs.base_dir = (char *) malloc(BUFSIZE))) {
|
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_find_local_ip(guess_ip, sizeof(guess_ip), NULL, AF_INET6);
|
||||||
switch_core_set_variable("local_ip_v6", guess_ip);
|
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_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("recordings_dir", SWITCH_GLOBAL_dirs.recordings_dir);
|
||||||
switch_core_set_variable("sound_prefix", SWITCH_GLOBAL_dirs.sounds_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("sounds_dir", SWITCH_GLOBAL_dirs.sounds_dir);
|
||||||
|
Reference in New Issue
Block a user