diff --git a/doc/asterisk.8 b/doc/asterisk.8 index e5991d9cf7dfbc96b252f7c9ff0d4a0a8ae92890..50ad8f6c11e9ca34a80142e9c830e811064cc769 100644 --- a/doc/asterisk.8 +++ b/doc/asterisk.8 @@ -158,6 +158,7 @@ too many simultaneous calls. .TP \-n Disable ANSI colors even on terminals capable of displaying them. +This option can be used only at startup (e.g. not with remote console). .TP \-p If supported by the operating system (and executing as root), @@ -195,7 +196,8 @@ then move them into the final location when done. .TP \-T Add timestamp to all non-command related output going to the console -when running with verbose and/or logging to the console. +when running with verbose and/or logging to the console. Can only be +used at startup (e.g. not with remote console mode). .TP \-U \fIuser\fR Run as user \fIuser\fR instead of the diff --git a/main/asterisk.c b/main/asterisk.c index de520a0b0bab6231c69473027b557b24e3c762fc..b965a4d5cc2a0a6627dcdcadb5203154c8a47fc5 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -3351,7 +3351,7 @@ static int show_cli_help(void) printf(" -L <load> Limit the maximum load average before rejecting new calls\n"); printf(" -M <value> Limit the maximum number of calls to the specified value\n"); printf(" -m Mute debugging and console output on the console\n"); - printf(" -n Disable console colorization\n"); + printf(" -n Disable console colorization. Can be used only at startup.\n"); printf(" -p Run as pseudo-realtime thread\n"); printf(" -q Quiet mode (suppress output)\n"); printf(" -r Connect to Asterisk on this machine\n"); @@ -3360,7 +3360,7 @@ static int show_cli_help(void) printf(" -t Record soundfiles in /var/tmp and move them where they\n"); printf(" belong after they are done\n"); printf(" -T Display the time in [Mmm dd hh:mm:ss] format for each line\n"); - printf(" of output to the CLI\n"); + printf(" of output to the CLI. Cannot be used with remote console mode.\n\n"); printf(" -v Increase verbosity (multiple v's = more verbose)\n"); printf(" -x <cmd> Execute command <cmd> (implies -r)\n"); printf(" -X Enable use of #exec in asterisk.conf\n"); @@ -3716,6 +3716,55 @@ int main(int argc, char *argv[]) } } + if (ast_opt_remote) { + int didwarn = 0; + optind = 1; + + /* Not all options can be used with remote console. Warn if they're used. */ + while ((c = getopt(argc, argv, getopt_settings)) != -1) { + switch (c) { + /* okay to run with remote console */ + case 'B': /* force black background */ + case 'd': /* debug */ + case 'h': /* help */ + case 'I': /* obsolete timing option: warning already thrown if used */ + case 'L': /* max load */ + case 'M': /* max calls */ + case 'R': /* reconnect */ + case 'r': /* remote */ + case 's': /* set socket path */ + case 'V': /* version */ + case 'v': /* verbose */ + case 'W': /* white background */ + case 'x': /* remote execute */ + case '?': /* ? */ + break; + /* can only be run when Asterisk is starting */ + case 'X': /* enables #exec for asterisk.conf only. */ + case 'C': /* set config path */ + case 'c': /* foreground console */ + case 'e': /* minimum memory free */ + case 'F': /* always fork */ + case 'f': /* no fork */ + case 'G': /* run group */ + case 'g': /* dump core */ + case 'i': /* init keys */ + case 'm': /* mute */ + case 'n': /* no color */ + case 'p': /* high priority */ + case 'q': /* quiet */ + case 'T': /* timestamp */ + case 't': /* cache record files */ + case 'U': /* run user */ + fprintf(stderr, "'%c' option is not compatible with remote console mode and has no effect.\n", c); + didwarn = 1; + } + } + if (didwarn) { + fprintf(stderr, "\n"); /* if any warnings print out, make them stand out */ + } + } + /* For remote connections, change the name of the remote connection. * We do this for the benefit of init scripts (which need to know if/when * the main asterisk process has died yet). */