2019-07-11 08:36:16 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
|
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-03-21 09:29:24 +00:00
|
|
|
#define __USE_XOPEN
|
2022-04-21 13:09:43 +00:00
|
|
|
#include "shellInt.h"
|
2022-09-07 02:16:00 +00:00
|
|
|
#include "shellAuto.h"
|
2022-03-21 09:29:24 +00:00
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
SShellObj shell = {0};
|
2022-03-21 09:29:24 +00:00
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2022-08-22 07:22:49 +00:00
|
|
|
shell.exit = false;
|
2022-07-23 01:35:00 +00:00
|
|
|
#ifdef WEBSOCKET
|
|
|
|
|
shell.args.timeout = 10;
|
|
|
|
|
shell.args.cloud = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
if (shellCheckIntSize() != 0) {
|
2022-04-21 13:11:02 +00:00
|
|
|
return -1;
|
2019-07-11 08:36:16 +00:00
|
|
|
}
|
2022-04-21 13:09:43 +00:00
|
|
|
|
|
|
|
|
if (shellParseArgs(argc, argv) != 0) {
|
2022-04-21 13:11:02 +00:00
|
|
|
return -1;
|
2019-07-11 08:36:16 +00:00
|
|
|
}
|
2022-04-21 13:09:43 +00:00
|
|
|
|
|
|
|
|
if (shell.args.is_version) {
|
|
|
|
|
shellPrintVersion();
|
2019-07-11 08:36:16 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
if (shell.args.is_gen_auth) {
|
|
|
|
|
shellGenerateAuth();
|
|
|
|
|
return 0;
|
2019-07-11 08:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
if (shell.args.is_help) {
|
2022-04-22 09:59:41 +00:00
|
|
|
shellPrintHelp();
|
2022-04-21 13:09:43 +00:00
|
|
|
return 0;
|
2020-12-10 07:04:08 +00:00
|
|
|
}
|
2022-08-22 07:22:49 +00:00
|
|
|
#ifdef WEBSOCKET
|
2022-07-23 01:35:00 +00:00
|
|
|
shellCheckConnectMode();
|
|
|
|
|
#endif
|
2022-04-27 03:27:27 +00:00
|
|
|
taos_init();
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
if (shell.args.is_dump_config) {
|
|
|
|
|
shellDumpConfig();
|
|
|
|
|
taos_cleanup();
|
|
|
|
|
return 0;
|
2019-07-11 08:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
if (shell.args.is_startup || shell.args.is_check) {
|
|
|
|
|
shellCheckServerStatus();
|
|
|
|
|
taos_cleanup();
|
|
|
|
|
return 0;
|
2020-12-17 05:06:20 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-22 07:50:29 +00:00
|
|
|
if (shell.args.netrole != NULL) {
|
2022-04-21 13:09:43 +00:00
|
|
|
shellTestNetWork();
|
|
|
|
|
taos_cleanup();
|
|
|
|
|
return 0;
|
2019-07-11 08:36:16 +00:00
|
|
|
}
|
2022-04-19 08:50:25 +00:00
|
|
|
|
2022-09-07 02:16:00 +00:00
|
|
|
// support port feature
|
|
|
|
|
shellAutoInit();
|
|
|
|
|
int32_t ret = shellExecute();
|
|
|
|
|
shellAutoExit();
|
|
|
|
|
return ret;
|
2022-04-19 08:50:25 +00:00
|
|
|
}
|