diff options
author | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-11 19:56:57 +0000 |
---|---|---|
committer | qwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-11 19:56:57 +0000 |
commit | 13a0a893eba392996434bebbc26536258eaf0b4b (patch) | |
tree | f4307a35535725dbd543187c7da07e211716755b /main/asterisk.c | |
parent | d16db4e98198c31866c45f266581cbb863d8ec52 (diff) |
Add autosystemname setting to asterisk.conf
When enabled, it will set the systemname to be the hostname of the system
Issue 9713, patch by Juggie - slightly modified by me, to "failover" to localhost
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@63967 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index be8ef8c1d..c44e2cbd6 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -2374,6 +2374,7 @@ static void ast_readconfig(void) struct ast_config *cfg; struct ast_variable *v; char *config = AST_CONFIG_FILE; + char hostname[MAXHOSTNAMELEN] = ""; if (ast_opt_override_config) { cfg = ast_config_load(ast_config_AST_CONFIG_FILE); @@ -2523,6 +2524,15 @@ static void ast_readconfig(void) ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP)); } else if (!strcasecmp(v->name, "systemname")) { ast_copy_string(ast_config_AST_SYSTEM_NAME, v->value, sizeof(ast_config_AST_SYSTEM_NAME)); + } else if (!strcasecmp(v->name, "autosystemname")) { + if (ast_true(v->value)) { + if (!gethostname(hostname, sizeof(hostname) - 1)) + ast_copy_string(ast_config_AST_SYSTEM_NAME, hostname, sizeof(ast_config_AST_SYSTEM_NAME)); + else { + ast_log(LOG_ERROR, "Cannot obtain hostname for this system. Using 'localhost' instead.\n"); + ast_copy_string(ast_config_AST_SYSTEM_NAME, "localhost", sizeof(ast_config_AST_SYSTEM_NAME)); + } + } } else if (!strcasecmp(v->name, "languageprefix")) { ast_language_is_prefix = ast_true(v->value); #if defined(HAVE_SYSINFO) |