]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add api_on_startup
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 15 Dec 2011 21:43:44 +0000 (15:43 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 15 Dec 2011 21:43:44 +0000 (15:43 -0600)
src/switch_core.c

index e07616d1325f5745dab33163c3653122e12e5c35..e64c6156fb2f89d5fd33fac3dc846bd5d24fe35e 100644 (file)
@@ -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;
 
 }