From a1613a17b7973f6df4fdc358899f62f710cd89cd Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Thu, 5 Dec 2024 14:43:14 +0800 Subject: [PATCH] [Optimization] Optimize some script (#4006) Co-authored-by: Zzm0809 Co-authored-by: GH Action - Upstream Sync --- script/bin/auto.sh | 64 +++++++++++----- script/bin/init_check_network.sh | 1 + script/bin/init_db.sh | 85 ++++++++++++--------- script/bin/init_env.sh | 53 +++++++++++++ script/bin/init_flink_dependences.sh | 1 + script/bin/init_hadoop_dependences.sh | 3 +- script/bin/init_jdbc_driver.sh | 19 +++++ script/bin/init_tools_main.sh | 103 +++++++++++++++++++++----- 8 files changed, 255 insertions(+), 74 deletions(-) create mode 100644 script/bin/init_env.sh create mode 100644 script/bin/init_jdbc_driver.sh diff --git a/script/bin/auto.sh b/script/bin/auto.sh index 339b5374c8..37b10141f3 100644 --- a/script/bin/auto.sh +++ b/script/bin/auto.sh @@ -1,8 +1,34 @@ #!/bin/bash - # debug mode #set -x +export RED='\033[31m' +export GREEN='\033[32m' +export YELLOW='\033[33m' +export BLUE='\033[34m' +export MAGENTA='\033[35m' +export CYAN='\033[36m' +export RESET='\033[0m' + + + +if [ -z "${DINKY_HOME}" ]; then + echo -e "${RED}DINKY_HOME environment variable is not set. Attempting to determine the correct path...${RESET}" + + SOURCE="${BASH_SOURCE[0]}" + while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" + done + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + export DINKY_HOME="$(dirname "$DIR")" + echo -e "${GREEN}DINKY_HOME is set to: ${DINKY_HOME}${RESET}" +else + echo -e "${GREEN}DINKY_HOME is already set to: ${DINKY_HOME}${RESET}" +fi + + FLINK_VERSION=${2} DINKY_HOME=${DINKY_HOME:-$(cd "$(dirname "$0")"; cd ..; pwd)} @@ -34,13 +60,13 @@ if [ -z "${FLINK_VERSION}" ]; then fi fi -echo "DINKY_HOME : ${APP_HOME} , JAVA_VERSION : ${JAVA_VERSION} , FLINK_VERSION : ${FLINK_VERSION}" +echo -e "${GREEN}DINKY_HOME : ${APP_HOME} , JAVA_VERSION : ${JAVA_VERSION} , FLINK_VERSION : ${FLINK_VERSION} ${RESET}" # Check whether the flink version is specified assertIsInputVersion() { # If FLINK_VERSION is still empty, prompt the user to enter the Flink version if [ -z "${FLINK_VERSION}" ]; then - echo "The flink version is not specified and the flink version cannot be found under the extends directory. Please specify the flink version." + echo -e "${RED}The flink version is not specified and the flink version cannot be found under the extends directory. Please specify the flink version${RESET}" exit 1 fi } @@ -74,21 +100,21 @@ JVM_OPTS="-Xms512M -Xmx2048M -XX:PermSize=512M -XX:MaxPermSize=1024M" PID_PATH="${APP_HOME}/run" if [ -d "${PID_PATH}" ];then - echo "${PID_PATH} is already exist." >> /dev/null + echo -e "${GREEN} ${PID_PATH} is already exist.${PID_PATH}${RESET}" >> /dev/null else mkdir -p "${PID_PATH}" fi # Check whether the pid file exists if [ -f "${PID_PATH}/${PID_FILE}" ];then - echo "${PID_PATH}/${PID_FILE} is already exist." >> /dev/null + echo -e "${GREEN} ${PID_PATH}/${PID_FILE} is already exist. ${RESET}" >> /dev/null else touch "${PID_PATH}"/${PID_FILE} fi tips() { echo "" - echo "WARNING!!!......Tips, please use command: sh auto.sh [start|startOnPending|startWithJmx|stop|restart|restartWithJmx|status]. For example: sh auto.sh start " + echo -e "${YELLOW}WARNING!!!......Tips, please use command: sh auto.sh [start|startOnPending|startWithJmx|stop|restart|restartWithJmx|status]. For example: sh auto.sh start ${RESET}" echo "" exit 1 } @@ -104,10 +130,10 @@ start() { if [ -z "$pid" ]; then nohup java ${PARAMS_OPT} ${JVM_OPTS} ${OOM_OPT} ${GC_OPT} -Xverify:none -cp "${CLASS_PATH}" org.dinky.Dinky ${JAR_PARAMS_OPT} > ${DINKY_LOG_PATH}/dinky-start.log 2>&1 & echo $! >"${PID_PATH}"/${PID_FILE} - echo "........................................Start Dinky Done........................................" - echo "current log path : ${DINKY_LOG_PATH}/dinky-start.log , you can execute tail -fn1000 ${DINKY_LOG_PATH}/dinky-start.log to watch the log" + echo -e "${GREEN}........................................Start Dinky Successfully........................................${RESET}" + echo -e "${GREEN}current log path : ${DINKY_LOG_PATH}/dinky-start.log , you can execute tail -fn1000 ${DINKY_LOG_PATH}/dinky-start.log to watch the log${RESET}" else - echo "Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!" + echo -e "$YELLOW Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!$RESET" fi } @@ -116,9 +142,9 @@ startOnPending() { updatePid if [ -z "$pid" ]; then java ${PARAMS_OPT} ${JVM_OPTS} ${OOM_OPT} ${GC_OPT} -Xverify:none -cp "${CLASS_PATH}" org.dinky.Dinky ${JAR_PARAMS_OPT} - echo "........................................Start Dinky Successfully........................................" + echo -e "$GREEN........................................Start Dinky Successfully........................................$RESET" else - echo "Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!" + echo -e "$YELLOW Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!$RESET" fi } @@ -129,10 +155,9 @@ startWithJmx() { nohup java ${PARAMS_OPT} ${JVM_OPTS} ${OOM_OPT} ${GC_OPT} -Xverify:none "${JMX}" -cp "${CLASS_PATH}" org.dinky.Dinky ${JAR_PARAMS_OPT} > ${DINKY_LOG_PATH}/dinky-start.log 2>&1 & # echo $! >"${PID_PATH}"/${PID_FILE} updatePid - echo "........................................Start Dinky with Jmx Successfully..................................... - ..." + echo -e "$GREEN........................................Start Dinky with Jmx Successfully........................................$RESET" else - echo "Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!" + echo -e "$YELLOW Dinky pid $pid is in ${PID_PATH}/${PID_FILE}, Please stop first !!!$RESET" fi } @@ -144,7 +169,7 @@ stop() { else kill -9 $pid sleep 1 - echo "........................................Stop Dinky Successfully....................................." + echo -e "$GREEN........................................Stop Dinky Successfully.....................................$RESET" rm -f "${PID_PATH}"/${PID_FILE} fi } @@ -153,12 +178,12 @@ status() { updatePid if [ -z $pid ]; then echo "" - echo "Service ${JAR_NAME} is not running!" + echo -e "${RED}Service ${JAR_NAME} is not running!${RESET}" echo "" exit 1 else echo "" - echo "Service ${JAR_NAME} is running. It's pid=${pid}" + echo -e "${GREEN}Service ${JAR_NAME} is running. It's pid=${pid}${RESET}" echo "" fi } @@ -168,7 +193,8 @@ restart() { assertIsInputVersion stop start - echo "........................................Restart Successfully........................................" + echo -e "${GREEN}........................................Restart Successfully........................................$RESET" + } restartWithJmx() { @@ -176,7 +202,7 @@ restartWithJmx() { assertIsInputVersion stop startWithJmx - echo "........................................Restart with Jmx Successfully........................................" + echo -e ".$GREEN.......................................Restart with Jmx Successfully........................................$RESET" } case "$1" in diff --git a/script/bin/init_check_network.sh b/script/bin/init_check_network.sh index 92335059a9..66b5cd105b 100644 --- a/script/bin/init_check_network.sh +++ b/script/bin/init_check_network.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x EXTERNAL_CONNECTIVITY_CHECK_URL="www.baidu.com" diff --git a/script/bin/init_db.sh b/script/bin/init_db.sh index 6c706dd4fc..22b7372ab2 100644 --- a/script/bin/init_db.sh +++ b/script/bin/init_db.sh @@ -1,62 +1,79 @@ #!/bin/bash +set -x -DINKY_HOME=$1 +DINKY_HOME_PARAMS=$1 +DB_ENV_FILE=$2 echo -e "${GREEN}====================== The database configuration file is initialized ======================${RESET}" -if [ -z "$DINKY_HOME" ]; then +if [ -z "$DINKY_HOME_PARAMS" ]; then echo -e "${RED}The parameter is wrong, please check!${RESET}" exit 1 fi while true; do - 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 + read -e -p "Please select a database type (1.MySQL 2.PostgresSQL):" db_type + while [ -z "$db_type" ]; do + read -e -p "Please select a database type (1.MySQL 2.PostgresSQL):" db_type + done + read -e -p "Please enter the database address (hostname or IP, default localhost): " -i "localhost" db_host + read -p "Please enter the database port : " db_port + read -e -p "Please enter a database name (default dinky): " -i "dinky" db_name + read -e -p "Please enter the database username (default dinky):" -i "dinky" db_username + read -s -p "Please enter the database password (default 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:]') - db_name=$(echo "$db_name" | tr -d '[:space:]') - db_username=$(echo "$db_username" | tr -d '[:space:]') - db_password=$(echo "$db_password" | tr -d '[:space:]') + + db_type=$(echo ${db_type} | tr -d '[:space:]') + db_host=$(echo ${db_host:-"localhost"} | tr -d '[:space:]') + db_name=$(echo ${db_name:-"dinky"}| tr -d '[:space:]') + db_username=$(echo ${db_username:-"dinky"} | tr -d '[:space:]') + db_password=$(echo ${db_password:-"dinky"} | tr -d '[:space:]') + if [ "$db_type" == 1 ]; then + db_port=$(echo ${db_port:-"3306"} | tr -d '[:space:]') + else + db_port=$(echo ${db_port:-"5432"} | tr -d '[:space:]') + fi + case $db_type in 1) echo -e "${YELLOW}Configuring MySQL database related information...${RESET}" - config_file="${DINKY_HOME}/config/application-mysql.yml" + config_file="${DINKY_HOME_PARAMS}/config/application-mysql.yml" 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 - echo "export MYSQL_USERNAME=${db_username}" >> /etc/profile - echo "export MYSQL_PASSWORD=${db_password}" >> /etc/profile - source /etc/profile + + add_to_env "DB_ACTIVE" "mysql" "$DB_ENV_FILE" + add_to_env "MYSQL_ADDR" "${db_host}:${db_port}" "$DB_ENV_FILE" + add_to_env "MYSQL_DATABASE" "${db_name}" "$DB_ENV_FILE" + add_to_env "MYSQL_USERNAME" "${db_username}" "$DB_ENV_FILE" + add_to_env "MYSQL_PASSWORD" "${db_password}" "$DB_ENV_FILE" + + + sleep 2 + source "$DB_ENV_FILE" 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 "^$" + grep -E '^(export DB_ACTIVE|export MYSQL_ADDR|export MYSQL_DATABASE|export MYSQL_USERNAME|export MYSQL_PASSWORD)' $DB_ENV_FILE | grep -v "^#" | grep -v "^$" break ;; 2) - echo -e "${YELLOW}Configuring PostgresSQL database related information...${RESET}" - config_file="${DINKY_HOME}/config/application-pgsql.yml" + echo -e "${YELLOW}Configuring PostgresSQL database related information...${RESET}" + config_file="${DINKY_HOME_PARAMS}/config/application-postgresql.yml" - 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}" + 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}" - 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 - echo "export POSTGRES_USER=${db_username}" >> /etc/profile - echo "export POSTGRES_PASSWORD=${db_password}" >> /etc/profile - source /etc/profile + add_to_env "DB_ACTIVE" "postgresql" "$DB_ENV_FILE" + add_to_env "POSTGRES_ADDR" "${db_host}:${db_port}" "$DB_ENV_FILE" + add_to_env "POSTGRES_DB" "${db_name}" "$DB_ENV_FILE" + add_to_env "POSTGRES_USER" "${db_username}" "$DB_ENV_FILE" + add_to_env "POSTGRES_PASSWORD" "${db_password}" "$DB_ENV_FILE" + sleep 2 + source $DB_ENV_FILE - 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 + 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)' $DB_ENV_FILE | grep -v "^#" | grep -v "^$" + + break ;; *) echo -e "${RED}The entered database type is incorrect, please select the correct database type again.${RESET}" diff --git a/script/bin/init_env.sh b/script/bin/init_env.sh new file mode 100644 index 0000000000..94242d380c --- /dev/null +++ b/script/bin/init_env.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -x + +DINKY_HOME_PARAMS=$1 +ENV_FILE=$2 + + +echo -e "${GREEN}Start configuring DINKY_HOME environment variable...${RESET}" + +echo -e "${GREEN}DINKY_HOME environment variable has not been configured, please choose whether to configure.${RESET}" +echo -e "${GREEN}1. Use the automatically obtained DINKY_HOME environment variable${RESET}" +echo -e "${GREEN}2. Manually enter the path of DINKY_HOME${RESET}" +echo -e "${GREEN}3. Cancel configuration${RESET}" +while true; do + read -p "Please enter your choice(1/2/3):" DINKY_HOME_CHOICE + case $DINKY_HOME_CHOICE in + 1) + echo -e "${GREEN}Use the automatically obtained DINKY_HOME environment variable${RESET}" + echo -e "${GREEN} The currently obtained path is: $DINKY_HOME_PARAMS to perform automatic configuration${RESET}" + add_to_env "DINKY_HOME" "$DINKY_HOME_PARAMS" "$ENV_FILE" + add_to_env "PATH" "\$DINKY_HOME/bin" "$ENV_FILE" + sleep 2 + source $ENV_FILE + echo -e "${GREEN}DINKY_HOME environment variable configuration completed. Please confirm whether the following configuration is correct:${RESET}" + grep -E '^(export DINKY_HOME)' $ENV_FILE | grep -v "^#" | grep -v "^$" + break + ;; + 2) + read -p "Please enter the path of DINKY_HOME:" dinky_home_path + dinky_home_path=$(echo "$dinky_home_path" | tr -d '[:space:]') + if [ ! -d "$dinky_home_path" ]; then + echo -e "${RED}The path does not exist, please re-enter${RESET}" + read -p "Please enter the path of DINKY_HOME:" dinky_home_path + else + echo -e "${GREEN}The path you entered is: $dinky_home_path${RESET}" + add_to_env "DINKY_HOME" "$dinky_home_path" "$ENV_FILE" + add_to_env "PATH" "\$DINKY_HOME/bin" "$ENV_FILE" + sleep 2 + source $ENV_FILE + echo -e "${GREEN}DINKY_HOME environment variable configuration completed. Please confirm whether the following configuration is correct:${RESET}" + grep -E '^(export DINKY_HOME)' $ENV_FILE | grep -v "^#" | grep -v "^$" + fi + break + ;; + 3) + echo -e "${GREEN}Cancel configuration${RESET}" + break + ;; + *) + echo -e "${RED}Invalid input, please re-run the script to select the correct option.${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 4b7092e93f..451d3b214d 100644 --- a/script/bin/init_flink_dependences.sh +++ b/script/bin/init_flink_dependences.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x CURRENT_FLINK_FULL_VERSION=$1 FLINK_VERSION_SCAN=$2 diff --git a/script/bin/init_hadoop_dependences.sh b/script/bin/init_hadoop_dependences.sh index e61526413c..c080a44188 100644 --- a/script/bin/init_hadoop_dependences.sh +++ b/script/bin/init_hadoop_dependences.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -x EXTENDS_HOME=$1 @@ -31,5 +32,3 @@ case $hadoop_uber_version in echo -e "${RED}The entered version number is incorrect, please re-run the script to select the correct version.${RESET}" ;; esac - -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_jdbc_driver.sh b/script/bin/init_jdbc_driver.sh new file mode 100644 index 0000000000..63631af604 --- /dev/null +++ b/script/bin/init_jdbc_driver.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -x + +DINKY_LIB_DIR=$1 + +echo -e "${GREEN}Start downloading the mysql driver package...${RESET}" +if [ -f "${DINKY_LIB_DIR}/mysql-connector-j-8.4.0.jar" ]; then + echo -e "${YELLOW}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}Download is complete, please verify. The downloaded file storage address is: ${DINKY_LIB_DIR}/mysql-connector-j-8.4.0.jar${RESET}" + if [ -f "${DINKY_LIB_DIR}/mysql-connector-j-8.4.0.jar" ]; then + echo -e "${GREEN}mysql driver package downloaded successfully。${RESET}" + else + echo -e "${RED}Mysql driver package download failed, please check the network or download manually。${RESET}" + exit 1 + fi + echo -e "${GREEN}After the verification is completed, subsequent installation and configuration operations can be performed as needed.。${RESET}" +fi \ No newline at end of file diff --git a/script/bin/init_tools_main.sh b/script/bin/init_tools_main.sh index dea59e73ac..1b2aae6821 100644 --- a/script/bin/init_tools_main.sh +++ b/script/bin/init_tools_main.sh @@ -1,4 +1,26 @@ #!/bin/bash +set -x + +ENV_FILE="/etc/profile.d/dinky_env" +if [ -f "${ENV_FILE}" ]; then + source "${ENV_FILE}" +else + echo "" > "${ENV_FILE}" + source "${ENV_FILE}" +fi + +DB_ENV_FILE="/etc/profile.d/dinky_db" +if [ -f "${DB_ENV_FILE}" ]; then + source "${DB_ENV_FILE}" +else + echo "" > "${DB_ENV_FILE}" + source "${DB_ENV_FILE}" +fi +chmod 755 $ENV_FILE +chmod 755 $DB_ENV_FILE + +source /etc/profile + export RED='\033[31m' export GREEN='\033[32m' @@ -15,7 +37,6 @@ echo -e "${GREEN}=============================================================== echo -e "${GREEN}======================================================================${RESET}" APP_HOME=${DINKY_HOME:-$(cd "$(dirname "$0")"; cd ..; pwd)} -export DINKY_HOME=${APP_HOME} sudo chmod +x "${APP_HOME}"/bin/init_*.sh @@ -82,6 +103,56 @@ function download_file() { export -f download_file +add_to_env() { + local var_name=$1 + local var_value=$2 + local file=$3 + echo "Adding $var_name to $file" + echo "export $var_name=\"$var_value\"" >> "$file" +# +# if ! grep -q "^export $var_name=" "$file"; then +# echo "Adding $var_name to $file" +# echo "export $var_name=\"$var_value\"" >> "$file" +# else +# echo "$var_name already exists in $file, skipping." +# fi +} +export -f add_to_env + + + +echo +echo + +echo -e "${GREEN} ====================== Environment variable initialization script -> Start ====================== ${RESET}" +DINKY_HOME_TMP=$(echo $DINKY_HOME) +if [ -z "$DINKY_HOME_TMP" ]; then + while true; do + read -p "Do you need to configure the DINKY_HOME environment variable? (yes/no):" is_init_dinky_home + is_init_dinky_home=$(echo "$is_init_dinky_home" | tr '[:upper:]' '[:lower:]' | tr -d '[:space:]') + case $is_init_dinky_home in + yes | y) + sh "${APP_HOME}"/bin/init_env.sh ${APP_HOME} ${ENV_FILE} + echo -e "${GREEN}DINKY_HOME environment variable configuration completed. the configuration file is:${ENV_FILE} ${RESET}" + break + ;; + no | n) + echo -e "${GREEN}Skip DINKY_HOME environment variable configuration.${RESET}" + break + ;; + *) + echo -e "${RED}The entered value is incorrect, please rerun the script to select the correct value.${RESET}" + ;; + esac + done +else + echo -e "${GREEN}DINKY_HOME environment variable has been configured at ${DINKY_HOME_TMP},Skip configuration.${RESET}" +fi + + +echo -e "${GREEN} ====================== Environment variable initialization script -> End ====================== ${RESET}" + + echo echo echo -e "${GREEN} ====================== Data source driver initialization script -> Start ====================== ${RESET}" @@ -97,20 +168,7 @@ while true; do read -p "Please enter your database type:" db_type case $db_type in 1) - 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 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}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 driver package downloaded successfully。${RESET}" - else - echo -e "${RED}Mysql driver package download failed, please check the network or download manually。${RESET}" - exit 1 - fi - echo -e "${GREEN}After the verification is completed, subsequent installation and configuration operations can be performed as needed.。${RESET}" - fi + sh "${APP_HOME}"/bin/init_jdbc_driver.sh "${DINKY_LIB}" break ;; 2) @@ -219,15 +277,16 @@ while true; do 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}" + sh "${APP_HOME}/bin/init_db.sh" "${DINKY_HOME}" "${DB_ENV_FILE}" + echo -e "${GREEN}The database configuration file initialization script has been executed successfully the configuration file is:${DB_ENV_FILE} ${RESET}" break ;; no | n ) - 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}" + echo -e "${GREEN}The database initialization operation has been skipped, please manually configure the database ${APP_HOME}/config/application.yml file and ${DINKY_HOME}/config/application-[mysql/postgresql].yml file。${RESET}" break ;; exit | e ) - 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}" + echo -e "${GREEN}The script has exited, please manually configure the database ${APP_HOME}/config/application.yml file and ${APP_HOME}/config/application-[mysql/postgresql].yml file。${RESET}" exit 0 ;; *) @@ -235,4 +294,10 @@ while true; do ;; esac done -echo -e "${GREEN} ====================== Database configuration file initialization script -> End ====================== ${RESET}" \ No newline at end of file +echo -e "${GREEN} ====================== Database configuration file initialization script -> End ====================== ${RESET}" +echo +echo +echo -e "${RED}Note: To make these changes permanent, you may need to restart your terminal or run 'source $DB_ENV_FILE && source $ENV_FILE' ${RESET}" +echo -e "${RED}Note: To make these changes permanent, you may need to restart your terminal or run 'source $DB_ENV_FILE && source $ENV_FILE' ${RESET}" +echo -e "${RED}Note: To make these changes permanent, you may need to restart your terminal or run 'source $DB_ENV_FILE && source $ENV_FILE' ${RESET}" +echo