Skip to content

Commit

Permalink
Fix automation script path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Dec 9, 2024
1 parent 495db25 commit a402692
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
36 changes: 36 additions & 0 deletions script/bin/init_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

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 [ -f /etc/profile.d/dinky_env ]; then
source /etc/profile.d/dinky_env
fi

if [ -z "$DINKY_HOME" ]; then
echo -e "${RED}DINKY_HOME is not set, please check the environment variable...${RESET}"
exit 1
else
EXTENDS_HOME="$DINKY_HOME"/extends
FLINK_VERSION_SCAN=$(ls -n "${EXTENDS_HOME}" | grep '^d' | grep flink | awk -F 'flink' '{print $2}')

echo -e "${GREEN}>>>>>>>>>>>>>>>>>>>. Start cleaning up the environment... <<<<<<<<<<<<<<<<<<<<${RESET}"
echo -e "${GREEN}Cleaning up the environment variables...${RESET}"
rm -rf /etc/profile.d/dinky_*
echo -e "${GREEN}Cleaning up the flink jar dependencies...${RESET}"
rm -rf "${EXTENDS_HOME}"/flink"${FLINK_VERSION_SCAN}"/flink-*
echo -e "${GREEN}Cleaning up the flink shaded hadoop jar dependencies...${RESET}"
rm -rf "${EXTENDS_HOME}"/flink-shaded-hadoop-*
echo -e "${GREEN}Cleaning up the mysql jar dependencies...${RESET}"
rm -rf "$DINKY_HOME"/lib/mysql-connector-*
echo -e "${GREEN}Cleaning up the environment variables of DINKY_HOME ...${RESET}"
unset DINKY_HOME
echo -e "${GREEN}Refresh environment variables...${RESET}"
source /etc/profile
echo -e "${GREEN}Environment cleanup completed...${RESET}"
fi
30 changes: 17 additions & 13 deletions script/bin/init_flink_dependences.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,30 @@ if [ -z "$CURRENT_FLINK_FULL_VERSION" ] || [ -z "$FLINK_VERSION_SCAN" ] || [ -z
exit 1
fi

if [ -f "$DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz" ]; then
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
if [ -d "$DINKY_TMP_DIR/flink-${CURRENT_FLINK_FULL_VERSION}" ]; then
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}
FLINK_STORE_DIR=${DINKY_TMP_DIR}/flink-download

mkdir -p ${FLINK_STORE_DIR}

if [ -f "${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz" ]; then
echo -e "${YELLOW}${FLINK_STORE_DIR} ALREADY EXISTS flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz file,To ensure completeness, delete first ${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz Download the file again${RESET}"
rm -rf ${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz
if [ -d "${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}" ]; then
echo -e "${YELLOW}The flink directory already exists, delete it ${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}"
rm -rf ${FLINK_STORE_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}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 "${GREEN}Start downloading the Flink-${FLINK_VERSION_SCAN} installation package... Store it in the ${FLINK_STORE_DIR} directory${RESET}"
if download_file "$tsinghua_url" "${FLINK_STORE_DIR}"; then
echo -e "${BLUE}The address of the currently downloaded Flink installation package is:${tsinghua_url}${RESET}"
return 0
else
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
if download_file "$apache_url" "${FLINK_STORE_DIR}"; then
echo -e "${BLUE}The address of the currently downloaded Flink installation package is:${apache_url}${RESET}"
return 0
else
Expand All @@ -52,7 +56,7 @@ fi
echo -e "${GREEN}Flink installation package download completed。${RESET}"
echo -e "\n${GREEN}===============================================================${RESET}\n"
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}/
tar -zxvf ${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}-bin-scala_2.12.tgz -C ${FLINK_STORE_DIR}/
if [ $? -eq 0 ]; then
echo -e "${GREEN}Flink installation package decompression completed。${RESET}"
else
Expand All @@ -62,8 +66,8 @@ fi

echo -e "\n${GREEN}===============================================================${RESET}\n"

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}"
flink_dir_tmp=$(ls -n ${FLINK_STORE_DIR} | grep '^d' | grep flink | awk '{print $9}')
full_flink_dir_tmp="${FLINK_STORE_DIR}/${flink_dir_tmp}"
echo -e "${BLUE}Unzipped directory name:${full_flink_dir_tmp}${RESET}"


Expand Down Expand Up @@ -101,6 +105,6 @@ ls -l ${EXTENDS_HOME}/flink${FLINK_VERSION_SCAN}/

echo -e "${YELLOW}Please check the above dependent files。${RESET}"

rm -rf ${DINKY_TMP_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}*
rm -rf ${FLINK_STORE_DIR}/flink-${CURRENT_FLINK_FULL_VERSION}*

echo -e "${GREEN}The basic dependency processing is completed, please perform subsequent operations according to the actual situation.${RESET}"
7 changes: 4 additions & 3 deletions script/bin/init_tools_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ echo -e "${GREEN}Dinky root path: ${APP_HOME} ${RESET}"

sudo chmod +x "${APP_HOME}"/bin/init_*.sh


/init_cleanup.sh
./init_tools_main.sh

EXTENDS_HOME="${APP_HOME}/extends"
if [ ! -d "${EXTENDS_HOME}" ]; then
Expand Down Expand Up @@ -209,7 +210,7 @@ while true; do
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} ==================================== 2. postgresql ========================================= ${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
Expand All @@ -220,7 +221,7 @@ while true; do
break
;;
2)
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}"
echo -e "${GREEN}It seems that postgresql 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)
Expand Down

0 comments on commit a402692

Please sign in to comment.