chore: refactor cus prompt (#20688)

* chore: refactor cus prompt

* fix: client name in install.sh

* fix: -Wno-reserved-user-defined-literal

* fix: update taos-tools commit

* fix: include/os/osDir.h

* fix: check cus name

* fix: makepkg.sh

* chore: update taos-tools d194dc9

---------

Co-authored-by: chenhaoran <haoran920c@163.com>
This commit is contained in:
Shuduo Sang 2023-03-30 19:30:54 +08:00 committed by GitHub
parent 333bbe73d5
commit 5e2b26f146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 121 additions and 34 deletions

View File

@ -121,7 +121,7 @@ ELSE ()
MESSAGE(STATUS "Compile with Address Sanitizer!") MESSAGE(STATUS "Compile with Address Sanitizer!")
ELSE () ELSE ()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
ENDIF () ENDIF ()
# disable all assert # disable all assert

View File

@ -2,7 +2,7 @@
# taos-tools # taos-tools
ExternalProject_Add(taos-tools ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
GIT_TAG e82b9fc GIT_TAG d194dc9
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR "" BINARY_DIR ""
#BUILD_IN_SOURCE TRUE #BUILD_IN_SOURCE TRUE

View File

@ -31,21 +31,49 @@
extern "C" { extern "C" {
#endif #endif
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h"
#endif
#ifdef WINDOWS #ifdef WINDOWS
#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\" #define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\"
#ifdef CUS_NAME
#define TD_CFG_DIR_PATH "C:\\"CUS_NAME"\\cfg\\"
#define TD_DATA_DIR_PATH "C:\\"CUS_NAME"\\data\\"
#define TD_LOG_DIR_PATH "C:\\"CUS_NAME"\\log\\"
#else
#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\" #define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\"
#define TD_DATA_DIR_PATH "C:\\TDengine\\data\\" #define TD_DATA_DIR_PATH "C:\\TDengine\\data\\"
#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" #define TD_LOG_DIR_PATH "C:\\TDengine\\log\\"
#endif // CUS_NAME
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
#ifdef CUS_PROMPT
#define TD_TMP_DIR_PATH "/tmp/"CUS_PROMPT"d/"
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
#else
#define TD_TMP_DIR_PATH "/tmp/taosd/" #define TD_TMP_DIR_PATH "/tmp/taosd/"
#define TD_CFG_DIR_PATH "/etc/taos/" #define TD_CFG_DIR_PATH "/etc/taos/"
#define TD_DATA_DIR_PATH "/var/lib/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/"
#define TD_LOG_DIR_PATH "/var/log/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/"
#endif // CUS_PROMPT
#else #else
#define TD_TMP_DIR_PATH "/tmp/" #define TD_TMP_DIR_PATH "/tmp/"
#ifdef CUS_PROMPT
#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/"
#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/"
#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/"
#else
#define TD_CFG_DIR_PATH "/etc/taos/" #define TD_CFG_DIR_PATH "/etc/taos/"
#define TD_DATA_DIR_PATH "/var/lib/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/"
#define TD_LOG_DIR_PATH "/var/log/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/"
#endif // CUS_PROMPT
#endif #endif
typedef struct TdDir *TdDirPtr; typedef struct TdDir *TdDirPtr;

31
include/util/cus_name.h Normal file
View File

@ -0,0 +1,31 @@
/*
* 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/>.
*/
#ifndef _CUS_NAME_H_
#define _CUS_NAME_H_
#ifndef CUS_NAME
#define CUS_NAME "TDengine"
#endif
#ifndef CUS_PROMPT
#define CUS_PROMPT "taos"
#endif
#ifndef CUS_EMAIL
#define CUS_EMAIL "<support@taosdata.com>"
#endif
#endif // _CUS_NAME_H_

View File

@ -1,7 +1,6 @@
######################################################## ########################################################
# # # #
# Configuration # # Configuration #
# Any questions, please email support@taosdata.com #
# # # #
######################################################## ########################################################
@ -13,7 +12,7 @@
############### 1. Cluster End point ############################ ############### 1. Cluster End point ############################
# The end point of the first dnode in the cluster to be connected to when this dnode or a CLI `taos` is started # The end point of the first dnode in the cluster to be connected to when this dnode or the CLI utility is started
# firstEp hostname:6030 # firstEp hostname:6030
# The end point of the second dnode to be connected to if the firstEp is not available # The end point of the second dnode to be connected to if the firstEp is not available
@ -25,7 +24,7 @@
# The FQDN of the host on which this dnode will be started. It can be IP address # The FQDN of the host on which this dnode will be started. It can be IP address
# fqdn hostname # fqdn hostname
# The port for external access after this dnode is started # The port for external access after this dnode is started
# serverPort 6030 # serverPort 6030
# The maximum number of connections a dnode can accept # The maximum number of connections a dnode can accept
@ -96,7 +95,7 @@
# if free disk space is less than this value, this dnode will fail to start # if free disk space is less than this value, this dnode will fail to start
# minimalDataDirGB 2.0 # minimalDataDirGB 2.0
# enable/disable system monitor # enable/disable system monitor
# monitor 1 # monitor 1
# The following parameter is used to limit the maximum number of lines in log files. # The following parameter is used to limit the maximum number of lines in log files.
@ -114,8 +113,8 @@
# The following parameters are used for debug purpose only by this dnode. # The following parameters are used for debug purpose only by this dnode.
# debugFlag is a 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR # debugFlag is a 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR
# Available debug levels are: # Available debug levels are:
# 131: output warning and error # 131: output warning and error
# 135: output debug, warning and error # 135: output debug, warning and error
# 143: output trace, debug, warning and error to log # 143: output trace, debug, warning and error to log
# 199: output debug, warning and error to both screen and file # 199: output debug, warning and error to both screen and file
@ -130,7 +129,7 @@
# debug flag for util # debug flag for util
# uDebugFlag 131 # uDebugFlag 131
# debug flag for rpc # debug flag for rpc
# rpcDebugFlag 131 # rpcDebugFlag 131
# debug flag for jni # debug flag for jni
@ -139,7 +138,7 @@
# debug flag for query # debug flag for query
# qDebugFlag 131 # qDebugFlag 131
# debug flag for taosc driver # debug flag for client driver
# cDebugFlag 131 # cDebugFlag 131
# debug flag for dnode messages # debug flag for dnode messages

View File

@ -234,7 +234,9 @@ if [ "$verMode" == "cluster" ]; then
sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh
sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh
sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh
sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" remove_temp.sh cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'`
echo "domain is ${cusDomain}"
sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" remove_temp.sh
mv remove_temp.sh ${install_dir}/bin/remove.sh mv remove_temp.sh ${install_dir}/bin/remove.sh
fi fi
if [ "$verMode" == "cloud" ]; then if [ "$verMode" == "cloud" ]; then

View File

@ -30,6 +30,10 @@
#include "tsched.h" #include "tsched.h"
#include "ttime.h" #include "ttime.h"
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h"
#endif
#define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0 #define TSC_VAR_RELEASED 0
@ -541,9 +545,15 @@ void taos_init_imp(void) {
deltaToUtcInitOnce(); deltaToUtcInitOnce();
if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { char logDirName[64] = {0};
#ifdef CUS_PROMPT
snprintf(logDirName, 64, "%slog", CUS_PROMPT);
#else
snprintf(logDirName, 64, "taoslog");
#endif
if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
// ignore create log failed, only print // ignore create log failed, only print
printf(" WARING: Create taoslog failed:%s. configDir=%s\n", strerror(errno), configDir); printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir);
} }
if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) { if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) {

View File

@ -228,7 +228,11 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *input
taosExpandDir(inputCfgDir, cfgDir, PATH_MAX); taosExpandDir(inputCfgDir, cfgDir, PATH_MAX);
if (taosIsDir(cfgDir)) { if (taosIsDir(cfgDir)) {
#ifdef CUS_PROMPT
snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "%s.cfg", CUS_PROMPT, cfgDir);
#else
snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir); snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir);
#endif
} else { } else {
tstrncpy(cfgFile, cfgDir, sizeof(cfgDir)); tstrncpy(cfgFile, cfgDir, sizeof(cfgDir));
} }

View File

@ -17,6 +17,10 @@
#include "os.h" #include "os.h"
#include "taoserror.h" #include "taoserror.h"
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h"
#endif
#define PROCESS_ITEM 12 #define PROCESS_ITEM 12
#define UUIDLEN37 37 #define UUIDLEN37 37
@ -252,7 +256,11 @@ int32_t taosGetEmail(char *email, int32_t maxLen) {
#ifdef WINDOWS #ifdef WINDOWS
// ASSERT(0); // ASSERT(0);
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
#ifdef CUS_PROMPT
const char *filepath = "/usr/local/"CUS_PROMPT"/email";
#else
const char *filepath = "/usr/local/taos/email"; const char *filepath = "/usr/local/taos/email";
#endif // CUS_PROMPT
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ);
if (pFile == NULL) return false; if (pFile == NULL) return false;
@ -264,8 +272,12 @@ int32_t taosGetEmail(char *email, int32_t maxLen) {
taosCloseFile(&pFile); taosCloseFile(&pFile);
return 0; return 0;
#else
#ifdef CUS_PROMPT
const char *filepath = "/usr/local/"CUS_PROMPT"/email";
#else #else
const char *filepath = "/usr/local/taos/email"; const char *filepath = "/usr/local/taos/email";
#endif // CUS_PROMPT
TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ);
if (pFile == NULL) return false; if (pFile == NULL) return false;

View File

@ -26,10 +26,6 @@ ELSE ()
SET(LINK_WEBSOCKET "") SET(LINK_WEBSOCKET "")
ENDIF () ENDIF ()
IF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL)
ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging)
ENDIF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL)
IF (TD_LINUX AND TD_ALPINE) IF (TD_LINUX AND TD_ALPINE)
SET(LINK_ARGP "/usr/lib/libargp.a") SET(LINK_ARGP "/usr/lib/libargp.a")
ELSE () ELSE ()

View File

@ -19,18 +19,6 @@
#include "shellInt.h" #include "shellInt.h"
#ifndef CUS_NAME
char cusName[] = "TDengine";
#endif
#ifndef CUS_PROMPT
char cusPrompt[] = "taos";
#endif
#ifndef CUS_EMAIL
char cusEmail[] = "<support@taosdata.com>";
#endif
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) #if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
#include "cus_name.h" #include "cus_name.h"
#endif #endif
@ -92,7 +80,11 @@ void shellPrintHelp() {
#endif #endif
printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH); printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION); printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
printf("\r\n\r\nReport bugs to %s.\r\n", cusEmail); #ifdef CUS_EMAIL
printf("\r\n\r\nReport bugs to %s.\r\n", CUS_EMAIL);
#else
printf("\r\n\r\nReport bugs to %s.\r\n", "support@taosdata.com");
#endif
} }
#ifdef LINUX #ifdef LINUX
@ -104,7 +96,11 @@ void shellPrintHelp() {
#endif #endif
const char *argp_program_version = version; const char *argp_program_version = version;
const char *argp_program_bug_address = cusEmail; #ifdef CUS_EMAIL
const char *argp_program_bug_address = CUS_EMAIL;
#else
const char *argp_program_bug_address = "support@taosdata.com";
#endif
static struct argp_option shellOptions[] = { static struct argp_option shellOptions[] = {
{"host", 'h', "HOST", 0, SHELL_HOST}, {"host", 'h', "HOST", 0, SHELL_HOST},
@ -414,10 +410,19 @@ int32_t shellParseArgs(int32_t argc, char *argv[]) {
shell.info.clientVersion = shell.info.clientVersion =
"Welcome to the %s Command Line Interface, Client Version:%s\r\n" "Welcome to the %s Command Line Interface, Client Version:%s\r\n"
"Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n"; "Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n";
strcpy(shell.info.cusName, cusName); #ifdef CUS_NAME
sprintf(shell.info.promptHeader, "%s> ", cusPrompt); strcpy(shell.info.cusName, CUS_NAME);
#else
strcpy(shell.info.cusName, "TDengine");
#endif
char promptContinueFormat[32] = {0}; char promptContinueFormat[32] = {0};
sprintf(promptContinueFormat, "%%%zus> ", strlen(cusPrompt)); #ifdef CUS_PROMPT
sprintf(shell.info.promptHeader, "%s> ", CUS_PROMPT);
sprintf(promptContinueFormat, "%%%zus> ", strlen(CUS_PROMPT));
#else
sprintf(shell.info.promptHeader, "taos> ");
sprintf(promptContinueFormat, "%%%zus> ", strlen("taos"));
#endif
sprintf(shell.info.promptContinue, promptContinueFormat, " "); sprintf(shell.info.promptContinue, promptContinueFormat, " ");
shell.info.promptSize = strlen(shell.info.promptHeader); shell.info.promptSize = strlen(shell.info.promptHeader);
snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), snprintf(shell.info.programVersion, sizeof(shell.info.programVersion),