From 2bb7fe6586e092781ea6d4e78c6ec915285837cd Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Tue, 3 Dec 2024 17:17:28 +0800 Subject: [PATCH] Translate to English --- script/bin/init_check_network.sh | 13 +-- script/bin/init_db.sh | 41 +++---- script/bin/init_flink_dependences.sh | 73 ++++++------- script/bin/init_hadoop_dependences.sh | 23 ++-- script/bin/init_tools_main.sh | 152 ++++++++++++-------------- 5 files changed, 132 insertions(+), 170 deletions(-) diff --git a/script/bin/init_check_network.sh b/script/bin/init_check_network.sh index 1725aceb7a..92335059a9 100644 --- a/script/bin/init_check_network.sh +++ b/script/bin/init_check_network.sh @@ -2,17 +2,16 @@ EXTERNAL_CONNECTIVITY_CHECK_URL="www.baidu.com" -# 检查网络是否可以正常连接外网 通过 ping 和 curl 方式检测 -echo -e "${YELLOW}正在检测你的网络是否可以正常链接外网 (${EXTERNAL_CONNECTIVITY_CHECK_URL}) ...${RESET}" +echo -e "${YELLOW}Checking whether your network can connect to the Internet properly (${EXTERNAL_CONNECTIVITY_CHECK_URL}) ...${RESET}" if ! ping -c 1 ${EXTERNAL_CONNECTIVITY_CHECK_URL} &> /dev/null; then - echo -e "${RED}你的网络使用 ping 方式无法连接外网,请检查你的网络环境是否正常, 程序将再次尝试使用 curl 方式检测网络连接...${RESET}" + echo -e "${RED}Your network cannot connect to the Internet using ping mode, please check whether your network environment is normal, and the program will try to use curl mode to detect the network connection again...${RESET}" if ! curl -I -s --connect-timeout 5 ${EXTERNAL_CONNECTIVITY_CHECK_URL} -w '%{http_code}' | tail -n1 | grep "200" &> /dev/null; then - echo -e "${RED}你的网络使用 curl 方式也无法连接外网,请检查你的网络环境是否正常。${RESET}" - echo -e "${YELLOW}请注意,在某些网络环境中,防火墙或安全策略可能会阻止ICMP请求(也就是ping)。如果遇到这种情况,可使用 curl 方式检测网络连接。${RESET}" + echo -e "${RED}Your network cannot be connected to the Internet using curl mode, please check whether your network environment is normal。${RESET}" + echo -e "${YELLOW}Note that in some network environments, firewalls or security policies may block ICMP requests (i.e., pings). If this happens, you can use curl to detect the network connection.${RESET}" exit 1 else - echo -e "${GREEN}你的网络使用 curl 方式可以连接外网,继续进行下一步操作...${RESET}" + echo -e "${GREEN}Your network can use curl to connect to the Internet and proceed to the next step...${RESET}" fi else - echo -e "${GREEN}你的网络使用 ping 方式可以连接外网,继续进行下一步操作...${RESET}" + echo -e "${GREEN}Your network can use ping to connect to the Internet and proceed to the next step...${RESET}" fi \ No newline at end of file diff --git a/script/bin/init_db.sh b/script/bin/init_db.sh index 44ae0f1fbb..6c706dd4fc 100644 --- a/script/bin/init_db.sh +++ b/script/bin/init_db.sh @@ -2,25 +2,22 @@ DINKY_HOME=$1 -echo -e "${GREEN}====================== 数据库配置文件初始化 ======================${RESET}" -echo -e "${BLUE}参数: Dinky 根目录为:${DINKY_HOME}${RESET}" +echo -e "${GREEN}====================== The database configuration file is initialized ======================${RESET}" -# 检查参数 if [ -z "$DINKY_HOME" ]; then - echo -e "${RED}参数错误,请检查!${RESET}" + echo -e "${RED}The parameter is wrong, please check!${RESET}" exit 1 fi while true; do - read -p "请选择数据库类型(1.MySQL 2.PostgreSQL):" db_type - read -p "请输入数据库地址(主机名或IP, 默认 localhost): " -i "localhost" db_host - read -p "请输入数据库端口(默认 3306): " -i 3306 db_port - read -p "请输入数据库名称(默认 dinky): " -i "dinky" db_name - read -p "请输入数据库用户名(默认 dinky): " -i "dinky" db_username - read -s -p "请输入数据库密码(默认 dinky): " -i "dinky" db_password - echo # 新行,以便在输入密码后换行 + read -p "Please select a database type (1.MySQL 2.PostgresSQL):" db_type + read -p "Please enter the database address (hostname or IP, default localhost): " -i "localhost" db_host + read -p "Please enter the database port (default 3306): " -i 3306 db_port + read -p "Please enter a database name (default dinky): " -i "dinky" db_name + read -p "Please enter the database username (default dinky):" -i "dinky" db_username + read -s -p "Please enter the database password (default dinky):" -i "dinky" db_password + echo - # 转换为小写并去除空格 db_type=$(echo "$db_type" | tr -d '[:space:]') db_host=$(echo "$db_host" | tr -d '[:space:]') db_port=$(echo "$db_port" | tr -d '[:space:]') @@ -30,10 +27,9 @@ while true; do case $db_type in 1) - echo -e "${YELLOW}正在配置 MySQL 数据库相关信息...${RESET}" + echo -e "${YELLOW}Configuring MySQL database related information...${RESET}" config_file="${DINKY_HOME}/config/application-mysql.yml" - # 更新 application-mysql.yml 文件中的配置 - echo -e "${GREEN} 自动初始化脚本采用 export 环境变量的方式 支持数据源的环境变量加载, 配置文件为:${config_file} ${RESET}" + echo -e "${GREEN} The automatic initialization script uses the export environment variable method to support the loading of environment variables of the data source. The configuration file is:${config_file} ${RESET}" echo "export DB_ACTIVE=mysql" >> /etc/profile echo "export MYSQL_ADDR=${db_host}:${db_port}" >> /etc/profile echo "export MYSQL_DATABASE=${db_name}" >> /etc/profile @@ -41,17 +37,16 @@ while true; do echo "export MYSQL_PASSWORD=${db_password}" >> /etc/profile source /etc/profile - echo -e "${GREEN}MySQL 数据库相关信息配置完成。请确认以下配置是否正确:${RESET}" + echo -e "${GREEN}MySQLThe configuration of database related information is completed. Please confirm whether the following configuration is correct:${RESET}" grep -E '^(export DB_ACTIVE|export MYSQL_ADDR|export MYSQL_DATABASE|export MYSQL_USERNAME|export MYSQL_PASSWORD)' /etc/profile | grep -v "^#" | grep -v "^$" - break # 退出循环 + break ;; 2) - echo -e "${YELLOW}正在配置 PostgreSQL 数据库相关信息...${RESET}" + echo -e "${YELLOW}Configuring PostgresSQL database related information...${RESET}" config_file="${DINKY_HOME}/config/application-pgsql.yml" - echo -e "${GREEN}自动初始化脚本采用 export 环境变量的方式 支持数据源配置文件的环境变量加载, 配置文件为:${config_file} ${RESET}" + echo -e "${GREEN}The automatic initialization script uses the export environment variable method to support the loading of environment variables from the data source configuration file. The configuration file is:${config_file} ${RESET}" - # 将以下变量追加方式写入到 /etc/profile 文件中 echo "export DB_ACTIVE=pgsql" >> /etc/profile echo "export POSTGRES_ADDR=${db_host}:${db_port}" >> /etc/profile echo "export POSTGRES_DB=${db_name}" >> /etc/profile @@ -59,12 +54,12 @@ while true; do echo "export POSTGRES_PASSWORD=${db_password}" >> /etc/profile source /etc/profile - echo -e "${GREEN}PostgreSQL 数据库相关信息配置完成。请确认以下配置是否正确:${RESET}" + echo -e "${GREEN}PostgresSQL The configuration of database related information is completed. Please confirm whether the following configuration is correct:${RESET}" grep -E '^(export DB_ACTIVE|export POSTGRES_ADDR|export POSTGRES_DB|export POSTGRES_USER|export POSTGRES_PASSWORD)' /etc/profile | grep -v "^#" | grep -v "^$" - break # 退出循环 + break ;; *) - echo -e "${RED}输入的数据库类型不正确,请重新选择正确的数据库类型.${RESET}" + echo -e "${RED}The entered database type is incorrect, please select the correct database type again.${RESET}" ;; esac done \ No newline at end of file diff --git a/script/bin/init_flink_dependences.sh b/script/bin/init_flink_dependences.sh index fb7de9abfb..4b7092e93f 100644 --- a/script/bin/init_flink_dependences.sh +++ b/script/bin/init_flink_dependences.sh @@ -1,111 +1,104 @@ #!/bin/bash -# 拿到参数并赋值变量 CURRENT_FLINK_FULL_VERSION=$1 FLINK_VERSION_SCAN=$2 DINKY_TMP_DIR=$3 EXTENDS_HOME=$4 DINKY_HOME=$5 -echo -e "${GREEN}====================== Flink 依赖初始化 ======================${RESET}" +echo -e "${GREEN}====================== Flink dependency initialization ======================${RESET}" -echo -e "${BLUE}参数: 当前Flink版本为:${CURRENT_FLINK_FULL_VERSION},扫描的Flink版本为:${FLINK_VERSION_SCAN} ,临时目录为:${DINKY_TMP_DIR} ,扩展包目录为:${EXTENDS_HOME} ,Dinky 根目录为:${DINKY_HOME}${RESET}" +echo -e "${BLUE}Parameters: The current Flink version is:${CURRENT_FLINK_FULL_VERSION},The scanned Flink version is:${FLINK_VERSION_SCAN} ,The temporary directory is:${DINKY_TMP_DIR} ,The expansion package directory is:${EXTENDS_HOME} ,Dinky The root directory is:${DINKY_HOME}${RESET}" -# 检查参数 if [ -z "$CURRENT_FLINK_FULL_VERSION" ] || [ -z "$FLINK_VERSION_SCAN" ] || [ -z "$DINKY_TMP_DIR" ] || [ -z "$EXTENDS_HOME" ] || [ -z "$DINKY_HOME" ]; then - echo -e "${RED}参数错误,请检查!${RESET}" + echo -e "${RED}Parameter error, please check!${RESET}" exit 1 fi -# 检查是否已存在flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz 文件 if [ -f "$DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz" ]; then - echo -e "${YELLOW}$DINKY_TMP_DIR 下已存在 flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz 文件,为了确保完整性, 执行先删除 ${DINKY_TMP_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz 文件后重新下载${RESET}" + echo -e "${YELLOW}$DINKY_TMP_DIR ALREADY EXISTS flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz file,To ensure completeness, delete first ${DINKY_TMP_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz Download the file again${RESET}" rm -rf ${DINKY_TMP_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz - # 是否有解压之后的flink目录,有则删除 if [ -d "$DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION}" ]; then - echo -e "${YELLOW}已存在 flink 目录,删除 $DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION}" + echo -e "${YELLOW}The flink directory already exists, delete it $DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION}" rm -rf $DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION} fi fi -# 尝试从清华大学镜像下载 try_tsinghua_mirror() { local tsinghua_url="https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-${CURRENT_FLINK_FULL_VERSION}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz" local apache_url="https://archive.apache.org/dist/flink/flink-${CURRENT_FLINK_FULL_VERSION}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz" - echo -e "${GREEN}开始下载 Flink-${FLINK_VERSION_SCAN} 安装包... 存放至 ${DINKY_TMP_DIR} 目录下${RESET}" + echo -e "${GREEN}Start downloading the Flink-${FLINK_VERSION_SCAN} installation package... Store it in the ${DINKY_TMP_DIR} directory${RESET}" if download_file "$tsinghua_url" "$DINKY_TMP_DIR"; then - echo -e "${BLUE}当前下载的Flink安装包地址为:${tsinghua_url}${RESET}" + echo -e "${BLUE}The address of the currently downloaded Flink installation package is:${tsinghua_url}${RESET}" return 0 else - echo -e "${YELLOW}清华大学镜像中未找到文件,尝试从 Apache 官方源下载...${RESET}" + echo -e "${YELLOW}File not found in Tsinghua University mirror, try downloading from Apache official source...${RESET}" if download_file "$apache_url" "$DINKY_TMP_DIR"; then - echo -e "${BLUE}当前下载的Flink安装包地址为:${apache_url}${RESET}" + echo -e "${BLUE}The address of the currently downloaded Flink installation package is:${apache_url}${RESET}" return 0 else - echo -e "${RED}从 Apache 官方源下载也失败了,请检查网络或手动下载。${RESET}" + echo -e "${RED}Downloading from Apache official source also failed, please check the network or download manually。${RESET}" return 1 fi fi } -# 调用下载函数 if ! try_tsinghua_mirror; then exit 0 fi -echo -e "${GREEN}Flink安装包下载完成。${RESET}" +echo -e "${GREEN}Flink installation package download completed。${RESET}" echo -e "\n${GREEN}===============================================================${RESET}\n" -echo -e "${GREEN}开始解压Flink安装包...${RESET}" +echo -e "${GREEN}Start decompressing the Flink installation package...${RESET}" tar -zxvf ${DINKY_TMP_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz -C ${DINKY_TMP_DIR}/ if [ $? -eq 0 ]; then - echo -e "${GREEN}Flink安装包解压完成。${RESET}" + echo -e "${GREEN}Flink installation package decompression completed。${RESET}" else - echo -e "${RED}Flink安装包解压失败,请检查。${RESET}" + echo -e "${RED}Flink installation package failed to decompress, please check。${RESET}" exit 1 fi echo -e "\n${GREEN}===============================================================${RESET}\n" -# 查看并获取解压后的flink开头的目录名称 flink_dir_tmp=$(ls -n ${DINKY_TMP_DIR} | grep '^d' | grep flink | awk '{print $9}') full_flink_dir_tmp="${DINKY_TMP_DIR}/${flink_dir_tmp}" -echo -e "${BLUE}解压后的目录名称:${full_flink_dir_tmp}${RESET}" +echo -e "${BLUE}Unzipped directory name:${full_flink_dir_tmp}${RESET}" -echo -e "${GREEN}处理 ${full_flink_dir_tmp}/lib/flink-table-planner-loader* 文件...${RESET}" +echo -e "${GREEN}Process ${full_flink_dir_tmp}/lib/flink-table-planner-loader* file...${RESET}" rm -rf ${full_flink_dir_tmp}/lib/flink-table-planner-loader* -echo -e "${GREEN}处理完成。${RESET}" +echo -e "${GREEN}Processing completed。${RESET}" -echo -e "${GREEN}处理 ${full_flink_dir_tmp}/opt/flink-table-planner_2.12-*.jar 文件...${RESET}" +echo -e "${GREEN}Process ${full_flink_dir_tmp}/opt/flink-table-planner_2.12-*.jar file...${RESET}" mv ${full_flink_dir_tmp}/opt/flink-table-planner_2.12-*.jar ${full_flink_dir_tmp}/lib/ -echo -e "${GREEN}处理完成。${RESET}" +echo -e "${GREEN}Processing completed。${RESET}" -echo -e "${GREEN}处理 flink jar 依赖 到 dinky 中...${RESET}" +echo -e "${GREEN}Process flink jar dependencies into dinky...${RESET}" cp -r ${full_flink_dir_tmp}/lib/*.jar ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ -echo -e "${GREEN}jar 依赖处理完成。${RESET}" +echo -e "${GREEN}jar dependency processing completed。${RESET}" -echo -e "${GREEN}处理 flink-sql-client ...${RESET}" +echo -e "${GREEN}Process flink-sql-client ...${RESET}" cp -r ${full_flink_dir_tmp}/opt/flink-sql-client-*.jar ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ -echo -e "${GREEN}处理完成。${RESET}" +echo -e "${GREEN}Processing completed。${RESET}" -echo -e "${GREEN}处理 flink-cep-scala ...${RESET}" +echo -e "${GREEN}Process flink-cep-scala ...${RESET}" cp -r ${full_flink_dir_tmp}/opt/flink-cep-scala*.jar ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ -echo -e "${GREEN}处理完成。${RESET}" +echo -e "${GREEN}Processing completed。${RESET}" -echo -e "${GREEN}处理 flink-queryable-state-runtime ...${RESET}" +echo -e "${GREEN}Process flink-queryable-state-runtime ...${RESET}" cp -r ${full_flink_dir_tmp}/opt/flink-queryable-state-runtime*.jar ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ -echo -e "${GREEN}处理完成。${RESET}" +echo -e "${GREEN}Processing completed。${RESET}" -echo -e "${GREEN}处理 flink-state-processor-api ...${RESET}" +echo -e "${GREEN}Process flink-state-processor-api ...${RESET}" cp -r ${full_flink_dir_tmp}/opt/flink-state-processor-api*.jar ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ -echo -e "${GREEN}处理完成。${RESET}" +echo -e "${GREEN}Processing completed。${RESET}" -echo -e "${GREEN} ================= 列出 ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ 目录下的文件 ==============${RESET}" +echo -e "${GREEN} ================= List files in the ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ directory ==============${RESET}" ls -l ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/ -# 请核对以上依赖文件 -echo -e "${YELLOW}请核对以上依赖文件。${RESET}" -echo -e "${GREEN}基础依赖处理完成, 请根据实际情况进行后续操作。${RESET}" \ No newline at end of file +echo -e "${YELLOW}Please check the above dependent files。${RESET}" + +echo -e "${GREEN}The basic dependency processing is completed, please perform subsequent operations according to the actual situation.${RESET}" \ No newline at end of file diff --git a/script/bin/init_hadoop_dependences.sh b/script/bin/init_hadoop_dependences.sh index 30251c56d4..e61526413c 100644 --- a/script/bin/init_hadoop_dependences.sh +++ b/script/bin/init_hadoop_dependences.sh @@ -1,42 +1,35 @@ #!/bin/bash -# 拿到参数并赋值变量 EXTENDS_HOME=$1 -echo -e "${GREEN}====================== Hadoop 依赖初始化 ======================${RESET}" -echo -e "${BLUE}参数: 扩展包目录为:${EXTENDS_HOME}${RESET}" +echo -e "${GREEN}====================== Hadoop dependency initialization ======================${RESET}" -# 选择要下载的 Hadoop-uber 版本 -read -p "请选择要下载的 Hadoop-uber 版本(输入 2 或者 3):" hadoop_uber_version +read -p "Please select the Hadoop-uber version to download (enter 2 or 3):" hadoop_uber_version hadoop_uber_version=$(echo "$hadoop_uber_version" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]') -# 根据用户选择的版本下载相应的 Hadoop-uber 包 case $hadoop_uber_version in 2) - echo -e "${YELLOW}开始下载 Hadoop-uber 2 版本包...${RESET}" - # 检查是否已下载过 Hadoop-uber 包 + echo -e "${YELLOW}Start downloading Hadoop-uber 2 version package...${RESET}" if [ -f "$EXTENDS_HOME/flink-shaded-hadoop-2-uber-2.8.3-10.0.jar" ]; then - echo -e "${YELLOW}已存在 flink-shaded-hadoop-2-uber-2.8.3-10.0.jar 文件,无需重复下载。${RESET}" + echo -e "${YELLOW}The flink-shaded-hadoop-2-uber-2.8.3-10.0.jar file already exists and there is no need to download it again.${RESET}" else download_url="https://repo1.maven.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.8.3-10.0/flink-shaded-hadoop-2-uber-2.8.3-10.0.jar" download_file "$download_url" "$EXTENDS_HOME" fi ;; 3) - # 检查是否已下载过 Hadoop-uber 包 - # 检查是否已下载过 Hadoop-uber 包 if [ -f "$EXTENDS_HOME/flink-shaded-hadoop-3-uber-3.1.1.7.2.9.0-173-9.0.jar" ]; then - echo -e "${YELLOW}已存在 flink-shaded-hadoop-3-uber-3.1.1.7.2.9.0-173-9.0.jar 文件,无需重复下载。${RESET}" + echo -e "${YELLOW}The flink-shaded-hadoop-3-uber-3.1.1.7.2.9.0-173-9.0.jar file already exists and there is no need to download it again.${RESET}" else - echo -e "${YELLOW}开始下载 Hadoop-uber 3 版本包...${RESET}" + echo -e "${YELLOW}Start downloading Hadoop-uber 3 version package...${RESET}" download_url="https://repository.cloudera.com/artifactory/cloudera-repos/org/apache/flink/flink-shaded-hadoop-3-uber/3.1.1.7.2.9.0-173-9.0/flink-shaded-hadoop-3-uber-3.1.1.7.2.9.0-173-9.0.jar" download_file "$download_url" "$EXTENDS_HOME" fi ;; *) - echo -e "${RED}输入的版本号不正确,请重新运行脚本选择正确的版本。${RESET}" + echo -e "${RED}The entered version number is incorrect, please re-run the script to select the correct version.${RESET}" ;; esac -echo -e "${GREEN}下载完成,可按需进行后续安装配置操作。${RESET}" \ No newline at end of file +echo -e "${GREEN}After the download is completed, subsequent installation and configuration operations can be performed as needed.${RESET}" \ No newline at end of file diff --git a/script/bin/init_tools_main.sh b/script/bin/init_tools_main.sh index 1fbf6ee05d..dea59e73ac 100644 --- a/script/bin/init_tools_main.sh +++ b/script/bin/init_tools_main.sh @@ -1,8 +1,5 @@ #!/bin/bash - - -# 定义颜色变量 export RED='\033[31m' export GREEN='\033[32m' export YELLOW='\033[33m' @@ -11,15 +8,12 @@ export MAGENTA='\033[35m' export CYAN='\033[36m' export RESET='\033[0m' -# 输出欢迎图案 echo -e "${GREEN}=====================================================================${RESET}" echo -e "${GREEN}=====================================================================${RESET}" -echo -e "${GREEN}==================== 欢迎使用 Dinky 初始化脚本 =====================${RESET}" +echo -e "${GREEN}============ Welcome to the Dinky initialization script =============${RESET}" echo -e "${GREEN}======================================================================${RESET}" echo -e "${GREEN}======================================================================${RESET}" -# 获取安装的目录 APP_HOME 先从环境变量中获取,如果没有则使用脚本所在目录 -# 先拿 DINKY_HOME 环境变量,如果没有则使用脚本所在目录 APP_HOME=${DINKY_HOME:-$(cd "$(dirname "$0")"; cd ..; pwd)} export DINKY_HOME=${APP_HOME} @@ -29,125 +23,117 @@ sudo chmod +x "${APP_HOME}"/bin/init_*.sh EXTENDS_HOME="${APP_HOME}/extends" if [ ! -d "${EXTENDS_HOME}" ]; then - echo -e "${RED} ${EXTENDS_HOME} 目录不存在,请检查 ${RESET}" + echo -e "${RED} ${EXTENDS_HOME} Directory does not exist, please check${RESET}" exit 1 fi -# 获取Dinky部署的Flink对应的版本号 FLINK_VERSION_SCAN=$(ls -n "${EXTENDS_HOME}" | grep '^d' | grep flink | awk -F 'flink' '{print $2}') if [ -z "${FLINK_VERSION_SCAN}" ]; then - echo -e "${RED} Dinky 部署的目录下 ${EXTENDS_HOME} 不存在 Flink 相关版本, 无法进行初始化操作,请检查。 ${RESET}" + echo -e "${RED}There is no Flink related version in ${EXTENDS_HOME} in the directory where Dinky is deployed. The initialization operation cannot be performed. Please check. ${RESET}" exit 1 fi -# 临时目录 DINKY_TMP_DIR="${APP_HOME}/tmp" if [ ! -d "${DINKY_TMP_DIR}" ]; then - echo -e "${YELLOW}创建临时目录 ${DINKY_TMP_DIR}...${RESET}" + echo -e "${YELLOW}Create temporary directory ${DINKY_TMP_DIR}...${RESET}" mkdir -p "${DINKY_TMP_DIR}" - echo -e "${GREEN}临时目录创建完成${RESET}" + echo -e "${GREEN}The temporary directory is created${RESET}" fi # LIB DINKY_LIB="${APP_HOME}/lib" if [ ! -d "${DINKY_LIB}" ]; then - echo -e "${RED}${DINKY_LIB} 目录不存在,请检查。 ${RESET}" + echo -e "${RED}${DINKY_LIB} Directory does not exist, please check. ${RESET}" exit 1 fi # 函数:检查命令是否存在,不存在则尝试安装 check_command() { local cmd="$1" - echo -e "${BLUE}检查命令:$cmd 是否存在......${RESET}" + echo -e "${BLUE}Check if command: $cmd exists...${RESET}" if ! command -v "$cmd" &> /dev/null; then if [ "$cmd" == "yum" ]; then - echo -e "${YELLOW} 尝试使用yum安装缺失的命令...${RESET}" + echo -e "${YELLOW} Try using yum to install the missing command...${RESET}" sudo yum install -y "$cmd" elif [ "$cmd" == "apt-get" ]; then - echo -e "${YELLOW}尝试使用apt-get安装缺失的命令...${RESET}" + echo -e "${YELLOW}Try using apt-get to install the missing command...${RESET}" sudo apt-get install -y "$cmd" else - echo -e "${RED} $cmd 命令未找到,请手动安装后再运行此脚本。${RESET}" + echo -e "${RED} $cmd The command was not found. Please install it manually and then run this script.。${RESET}" exit 1 fi fi - echo -e "${GREEN}========== 命令 $cmd 检查完成。 OK, 继续执行脚本。 ==========${RESET}" + echo -e "${GREEN}========== Command $cmd check completed. OK, continue executing the script. ==========${RESET}" } sh "${APP_HOME}/bin/init_check_network.sh" -# 检查wget是否存在,不存在则尝试安装 check_command "wget" -echo -e "${GREEN}前置检查完成,欢迎使用 Dinky 初始化脚本,当前 Dinky 根路径为:${APP_HOME} ${RESET}" +echo -e "${GREEN}The pre-check is completed. Welcome to use the Dinky initialization script. The current Dinky root path is:${APP_HOME} ${RESET}" function download_file() { source_url=$1 target_file_dir=$2 - echo -e "${GREEN}开始下载 $source_url 到 $target_file_dir...${RESET}" + echo -e "${GREEN}Start downloading $source_url to $target_file_dir...${RESET}" wget -P "${target_file_dir}" "${source_url}" - echo -e "${GREEN}下载完成。下载的文件存放地址为: $target_file_dir ${RESET}" + echo -e "${GREEN}Download completed. The downloaded file storage address is: $target_file_dir ${RESET}" } -# 导出函数 export -f download_file echo echo -echo -e "${GREEN} ====================== 数据源驱动初始化脚本 -> 开始 ====================== ${RESET}" +echo -e "${GREEN} ====================== Data source driver initialization script -> Start ====================== ${RESET}" while true; do - # 步骤1:获取数据库类型,判断是否为mysql,若是则下载驱动包 - echo -e "${BLUE} ============ 请输入你的数据库类型 ================ ${RESET}" - echo -e "${BLUE} ======== (h2 默认自带不需要执行该步骤) =========== ${RESET}" - echo -e "${BLUE} ============== 请选择 1、2、3 ================== ${RESET}" - echo -e "${BLUE} ================ 1. mysql ===================== ${RESET}" - echo -e "${BLUE} ================ 2. pgsql ===================== ${RESET}" - echo -e "${BLUE} ================ 3. 跳过该步骤 ================== ${RESET}" - echo -e "${BLUE} ================ 输入数字选择 =================== ${RESET}" - read -p "请输入你的数据库类型:" db_type + echo -e "${BLUE} ========================= Please enter your database type ================================ ${RESET}" + echo -e "${BLUE} ======== (h2 comes with it by default and does not need to perform this step)=========== ${RESET}" + echo -e "${BLUE} ============================== Please select 1, 2, 3 ====================================== ${RESET}" + echo -e "${BLUE} ==================================== 1. mysql ============================================= ${RESET}" + echo -e "${BLUE} ==================================== 2. pgsql ========================================= ${RESET}" + echo -e "${BLUE} ================================ 3. Skip this step ========================================== ${RESET}" + echo -e "${BLUE} ================================ Enter number selection ================================== ${RESET}" + read -p "Please enter your database type:" db_type case $db_type in 1) - echo -e "${GREEN}开始下载 mysql 驱动包...${RESET}" - # 这里替换为真实有效的下载链接 - # 检查是否已经存在 + echo -e "${GREEN}Start downloading the mysql driver package...${RESET}" if [ -f "${DINKY_LIB}/mysql-connector-j-8.4.0.jar" ]; then - echo -e "${GREEN}mysql 驱动包已存在,无需重复下载。跳过该步骤。${RESET}" + echo -e "${GREEN}mysql The driver package already exists, no need to download it again. Skip this step。${RESET}" else download_file https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.4.0/mysql-connector-j-8.4.0.jar "${DINKY_LIB}" - echo -e "${GREEN}下载完成,校验一下。下载的文件存放地址为: ${DINKY_LIB}/mysql-connector-j-8.4.0.jar${RESET}" + echo -e "${GREEN}Download is complete, please verify. The downloaded file storage address is: ${DINKY_LIB}/mysql-connector-j-8.4.0.jar${RESET}" if [ -f "${DINKY_LIB}/mysql-connector-j-8.4.0.jar" ]; then - echo -e "${GREEN}mysql 驱动包下载成功。${RESET}" + echo -e "${GREEN}mysql driver package downloaded successfully。${RESET}" else - echo -e "${RED}mysql 驱动包下载失败,请检查网络或手动下载。${RESET}" + echo -e "${RED}Mysql driver package download failed, please check the network or download manually。${RESET}" exit 1 fi - echo -e "${GREEN}校验完成,可按需进行后续安装配置操作。${RESET}" + echo -e "${GREEN}After the verification is completed, subsequent installation and configuration operations can be performed as needed.。${RESET}" fi - break # 退出循环 + break ;; 2) - echo -e "${GREEN}貌似已经默认集成了 pgsql,无需执行该步骤。请按需进行后续安装配置操作。${RESET}" - break # 退出循环 + echo -e "${GREEN}It seems that pgsql has been integrated by default, so there is no need to perform this step. Please perform subsequent installation and configuration operations as needed.${RESET}" + break ;; 3) - echo -e "${GREEN}跳过该步骤。${RESET}" - break # 退出循环 + echo -e "${GREEN}Skip this step。${RESET}" + break ;; *) - echo -e "${RED}输入的数据库类型不正确,请重新运行脚本选择正确的数据库类型。${RESET}" + echo -e "${RED}The entered database type is incorrect, please rerun the script to select the correct database type.${RESET}" ;; esac done -echo -e "${GREEN} ====================== 数据源驱动初始化脚本 -> 结束 ====================== ${RESET}" +echo -e "${GREEN} ====================== Data source driver initialization script -> end====================== ${RESET}" echo echo -echo -e "${GREEN} ====================== Flink 依赖初始化脚本 -> 开始 ====================== ${RESET}" +echo -e "${GREEN} ====================== Flink depends on initialization script -> start ====================== ${RESET}" declare -A version_map -# 创建个 map key 是 1.20 value 是 1.20.0 version_map["1.14"]="1.14.6" version_map["1.15"]="1.15.4" version_map["1.16"]="1.16.3" @@ -158,99 +144,95 @@ version_map["1.20"]="1.20.0" FLINK_VERSION_SCAN=$(ls -n "${EXTENDS_HOME}" | grep '^d' | grep flink | awk -F 'flink' '{print $2}') if [ -z "${FLINK_VERSION_SCAN}" ]; then - echo -e "${RED}Dinky 部署的目录下 ${EXTENDS_HOME} 不存在 Flink 相关版本, 无法进行初始化操作,请检查。${RESET}" + echo -e "${RED}There is no Flink related version in ${EXTENDS_HOME} in the directory where Dinky is deployed. The initialization operation cannot be performed. Please check.${RESET}" exit 1 else - echo -e "${GREEN}当前 Dinky 部署的 Flink 版本号:${FLINK_VERSION_SCAN}${RESET}" + echo -e "${GREEN}The current Flink version number deployed by Dinky:${FLINK_VERSION_SCAN}${RESET}" fi # 根据 Dinky 部署的Flink对应的版本号,获取对应的 Flink 版本 CURRENT_FLINK_FULL_VERSION=${version_map[$FLINK_VERSION_SCAN]} -echo -e "${GREEN}根据扫描的当前 Flink 版本号获取 部署的 Flink 对应的版本号(全版本号)为:flink-${CURRENT_FLINK_FULL_VERSION}${RESET}" +echo -e "${GREEN}Obtain the version number corresponding to the deployed Flink (full version number) based on the scanned current Flink version number: flink-${CURRENT_FLINK_FULL_VERSION}${RESET}" # 步骤2:获取Dinky部署的Flink对应的版本号,然后下载Flink安装包 while true; do - read -p "检测到 Dinky 部署的Flink版本号为:${FLINK_VERSION_SCAN}, 需要下载的 Flink 安装包版本号为:flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz , 请选择是否初始化 Flink 相关依赖?(yes/no/exit)" is_init_flink + read -p "It is detected that the Flink version number deployed by Dinky is: ${FLINK_VERSION_SCAN}, and the Flink installation package version number that needs to be downloaded is: flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz. Please choose whether to initialize Flink related dependencies?(yes/no/exit)" is_init_flink is_init_flink=$(echo "$is_init_flink" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]') case $is_init_flink in yes | y ) sh "${APP_HOME}"/bin/init_flink_dependences.sh "${CURRENT_FLINK_FULL_VERSION}" "${FLINK_VERSION_SCAN}" "${DINKY_TMP_DIR}" "${EXTENDS_HOME}" "${APP_HOME}" - break # 退出循环 + break ;; no | n ) - echo -e "${GREEN}已跳过Flink安装包下载操作。请手动下载。${RESET}" - break # 退出循环 + echo -e "${GREEN}The Flink installation package download operation has been skipped. Please download manually${RESET}" + break ;; exit | e ) - echo -e "${GREEN}你选择了 exit,程序将退出。${RESET}" - exit 0 # 退出脚本 + echo -e "${GREEN}If you choose exit, the program will exit。${RESET}" + exit 0 ;; *) - echo -e "${RED}输入无效,请重新输入 yes/no/exit。${RESET}" + echo -e "${RED}Invalid input, please re-enter yes/no/exit。${RESET}" ;; esac done -echo -e "${GREEN} ====================== Flink 依赖初始化脚本 -> 结束 ====================== ${RESET}" +echo -e "${GREEN} ====================== Flink depends on initialization script -> end ====================== ${RESET}" echo echo -echo -e "${GREEN} ====================== Hadoop 依赖初始化脚本 -> 开始 ====================== ${RESET}" +echo -e "${GREEN} ====================== Hadoop dependency initialization script -> Start ====================== ${RESET}" -# 步骤:询问是否是Hadoop环境,若是则等待用户选择下载hadoop-uber的版本是2还是3 while true; do - read -p "你的部署环境是否是Hadoop环境?(yes/no/exit)" is_hadoop - # 将输入转换为小写,以便进行不区分大小写的比较 + read -p "Is your deployment environment a Hadoop environment??(yes/no/exit)" is_hadoop is_hadoop=$(echo "$is_hadoop" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]') case $is_hadoop in yes | y ) sh "${APP_HOME}/bin/init_hadoop_dependences.sh" "${EXTENDS_HOME}" - break # 退出循环 + break ;; no | n ) - echo -e "${GREEN}已跳过Hadoop相关操作。${RESET}" - break # 退出循环 + echo -e "${GREEN}Hadoop related operations skipped ${RESET}" + break ;; exit | e ) - echo -e "${GREEN}你选择了 exit,程序将退出。${RESET}" - exit 0 # 退出脚本 + echo -e "${GREEN}If you choose exit, the program will exit${RESET}" + exit 0 ;; *) - echo -e "${RED}输入无效,请重新输入 yes/no/exit。${RESET}" + echo -e "${RED}Invalid input, please re-enter yes/no/exit。${RESET}" ;; esac done -echo -e "${GREEN} ====================== Hadoop 依赖初始化脚本 -> 结束 ====================== ${RESET}" +echo -e "${GREEN} ======================Hadoop dependency initialization script -> end ====================== ${RESET}" echo -echo -e "${GREEN} === 环境初始化完成,接下来可以进行配置 Dinky 的 conf 目录下的 application 配置文件进行数据库相关配置, 或者执行初始化配置文件。==== ${RESET}" +echo -e "${GREEN} === After the environment initialization is completed, you can configure the application configuration file in Dinky's config directory to perform database-related configuration, or execute the initialization configuration file.。==== ${RESET}" echo -echo -e "${GREEN} ====================== 数据库配置文件初始化脚本 -> 开始 ====================== ${RESET}" +echo -e "${GREEN} ====================== Database configuration file initialization script -> Start ====================== ${RESET}" -# 初始化配置文件 while true; do - read -p "是否需要初始化数据库配置文件?(yes/no):" is_init_db - # 将输入转换为小写,以便进行不区分大小写的比较 + read -p "Do you need to initialize the database configuration file??(yes/no):" is_init_db is_init_db=$(echo "$is_init_db" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]') case $is_init_db in yes | y ) sh "${APP_HOME}/bin/init_db.sh" "${DINKY_HOME}" - break # 退出循环 + break ;; no | n ) - echo -e "${GREEN}已跳过数据库初始化操作, 请手动配置数据库 ${DINKY_HOME}/config/application.yml 文件和 ${DINKY_HOME}/config/application-[mysql/pgsql].yml 文件。${RESET}" - break # 退出循环 + echo -e "${GREEN}The database initialization operation has been skipped, please manually configure the database ${DINKY_HOME}/config/application.yml file and ${DINKY_HOME}/config/application-[mysql/pgsql].yml file。${RESET}" + break ;; exit | e ) - echo -e "${GREEN}已退出脚本,请手动配置数据库 ${DINKY_HOME}/config/application.yml 文件和 ${DINKY_HOME}/config/application-[mysql/pgsql].yml 文件。${RESET}" - exit 0 # 退出脚本 + echo -e "${GREEN}The script has exited, please manually configure the database ${DINKY_HOME}/config/application.yml file and ${DINKY_HOME}/config/application-[mysql/pgsql].yml file。${RESET}" + exit 0 ;; *) - echo -e "${RED}输入无效,请重新输入 yes/no/exit。${RESET}" + echo -e "${RED}Invalid input, please re-enter yes/no/exit。${RESET}" ;; esac done -echo -e "${GREEN} ====================== 数据库配置文件初始化脚本 -> 结束 ====================== ${RESET}" \ No newline at end of file +echo -e "${GREEN} ====================== Database configuration file initialization script -> End ====================== ${RESET}" \ No newline at end of file