From e164b76caf0a47b6b33891eea80b1928067c9dd1 Mon Sep 17 00:00:00 2001 From: Anthony Minessale <anthm@freeswitch.org> Date: Thu, 15 Dec 2011 15:43:44 -0600 Subject: [PATCH] add api_on_startup --- src/switch_core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/switch_core.c b/src/switch_core.c index e07616d132..e64c6156fb 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -1818,6 +1818,7 @@ SWITCH_DECLARE(const char *) switch_core_banner(void) SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t flags, switch_bool_t console, const char **err) { switch_event_t *event; + char *cmd; if (switch_core_init(flags, console, err) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_GENERR; @@ -1861,6 +1862,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t switch_clear_flag((&runtime), SCF_NO_NEW_SESSIONS); + if ((cmd = switch_core_get_variable_dup("api_on_startup"))) { + switch_stream_handle_t stream = { 0 }; + SWITCH_STANDARD_STREAM(stream); + switch_console_execute(cmd, 0, &stream); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Startup command [%s] executed. Output:\n%s\n", cmd, (char *)stream.data); + free(stream.data); + free(cmd); + } + return SWITCH_STATUS_SUCCESS; }