Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: codacy complain shell error #469

Merged
merged 3 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 28 additions & 52 deletions packaging/tools/install-taostools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ install_main_dir="/usr/local/taos"

# Color setting
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'

csudo=""
Expand All @@ -38,12 +37,13 @@ fi
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
if [[ -e /etc/os-release ]]; then
osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2) ||:
osinfo=$(grep "^NAME=" /etc/os-release | cut -d '"' -f2) ||:
else
osinfo=""
fi
#echo "osinfo: ${osinfo}"

os_type=0

if echo $osinfo | grep -qwi "ubuntu" ; then
# echo "This is ubuntu system"
os_type=1
Expand All @@ -62,19 +62,22 @@ elif echo $osinfo | grep -qwi "fedora" ; then
elif echo $osinfo | grep -qwi "Linx" ; then
# echo "This is Linx system"
os_type=1
else
echo " osinfo: ${osinfo}"
echo " This is an officially unverified linux system,"
echo " if there are any problems with the installation and operation, "
echo " please feel free to contact ${emailName} for support."
fi

if [ $os_type -ne 1 ] && [ $os_type -ne 2 ]; then
echo -e "${YELLOW}"
echo -e " This is an officially unverified linux system,"
echo -e " if there are any problems with the installation and operation, "
echo -e " please feel free to contact ${emailName} for support."
echo -e "${NC}"
os_type=1
fi

function kill_process() {
pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo}kill -9 $pid || :
fi
pid=$(ps -ef | grep "$1" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
${csudo}kill -9 $pid || :
fi
}

function install_main_path() {
Expand All @@ -86,9 +89,9 @@ function install_libtaosws() {
if [ -f ${script_dir}/driver/libtaosws.so ]; then
[ -d ${install_main_dir}/driver ] || ${csudo}mkdir ${install_main_dir}/driver ||:
[ -f ${install_main_dir}/driver/libtaosws.so ] || \
${csudo}/usr/bin/install -c -m 755 ${script_dir}/driver/libtaosws.so ${install_main_dir}/driver/libtaosws.so && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so /usr/lib/libtaosws.so
${csudo}/usr/bin/install -c -m 755 ${script_dir}/driver/libtaosws.so ${install_main_dir}/driver/libtaosws.so && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so /usr/lib/libtaosws.so || echo -e "${RED} failed to install libtaosws.so ${NC}"
if [ -d /usr/lib64 ]; then
${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so /usr/lib64/libtaosws.so
${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so /usr/lib64/libtaosws.so || echo -e "${RED}failed to link libtaosws.so to /usr/lib64 ${NC}"
fi
fi
}
Expand All @@ -100,61 +103,34 @@ function install_bin() {
${csudo}rm -f ${bin_link_dir}/${dumpName} || :
${csudo}rm -f ${bin_link_dir}/rm${toolsName} || :

${csudo}/usr/bin/install -c -m 755 ${script_dir}/bin/${dumpName} ${install_main_dir}/bin/${dumpName} || echo -e "taosdump not installed"
${csudo}/usr/bin/install -c -m 755 ${script_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${benchmarkName}
${csudo}/usr/bin/install -c -m 755 ${script_dir}/uninstall-${toolsName}.sh ${install_main_dir}/bin/uninstall-${toolsName}.sh
${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${demoName}
${csudo}/usr/bin/install -c -m 755 ${script_dir}/bin/${dumpName} ${install_main_dir}/bin/${dumpName} || echo -e "${RED}${dumpName}not installed${NC}"
${csudo}/usr/bin/install -c -m 755 ${script_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${benchmarkName} || echo -e "${RED}${benchmarkName}not installed${NC}"
${csudo}/usr/bin/install -c -m 755 ${script_dir}/uninstall-${toolsName}.sh ${install_main_dir}/bin/uninstall-${toolsName}.sh || echo -e "${RED}uninstall-${toolsName}not installed${NC}"
#Make link
[[ -x ${install_main_dir}/bin/${benchmarkName} ]] && \
${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${install_main_dir}/bin/${demoName} || :
[[ -x ${install_main_dir}/bin/${benchmarkName} ]] && \
${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
[[ -x ${install_main_dir}/bin/${demoName} ]] && \
${csudo}ln -s ${install_main_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || :
${csudo}ln -s ${install_main_dir}/bin/${demoName} ${bin_link_dir}/${demoName} || :
[[ -x ${install_main_dir}/bin/${dumpName} ]] && \
${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
[[ -x ${install_main_dir}/bin/uninstall-${toolsName}.sh ]] && \
${csudo}ln -s ${install_main_dir}/bin/uninstall-${toolsName}.sh ${bin_link_dir}/rm${toolsName} || :
${csudo}ln -s ${install_main_dir}/bin/uninstall-${toolsName}.sh ${bin_link_dir}/rm${toolsName} || :
}

function install_avro() {
if [ "$osType" != "Darwin" ]; then
avro_dir=${script_dir}/avro
if [ -f "${avro_dir}/lib/libavro.so.23.0.0" ] && [ -d /usr/local/$1 ]; then
${csudo}/usr/bin/install -c -d /usr/local/$1
${csudo}/usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.so.23.0.0 /usr/local/$1
${csudo}ln -sf /usr/local/$1/libavro.so.23.0.0 /usr/local/$1/libavro.so.23
${csudo}ln -sf /usr/local/$1/libavro.so.23 /usr/local/$1/libavro.so

${csudo}/usr/bin/install -c -d /usr/local/$1
[ -f ${avro_dir}/lib/libavro.a ] &&
${csudo}/usr/bin/install -c -m 755 ${avro_dir}/lib/libavro.a /usr/local/$1

if [ -d /etc/ld.so.conf.d ]; then
echo "/usr/local/$1" | ${csudo}tee /etc/ld.so.conf.d/libavro.conf > /dev/null || echo -e "failed to write /etc/ld.so.conf.d/libavro.conf"
${csudo}ldconfig
else
echo "/etc/ld.so.conf.d not found!"
fi
fi
fi
}


function install_taostools() {
# Start to install
echo -e "${GREEN}Start to install ${taosName} tools ...${NC}"

install_main_path

# install_avro lib
# install_avro lib64


# For installing new
install_bin
install_libtaosws

echo
echo -e "\033[44;32;1m${taosName} tools is installed successfully!${NC}"
echo -e "${GREEN}${taosName} tools is installed successfully!${NC}"
}

## ==============================Main program starts from here============================
Expand Down
5 changes: 1 addition & 4 deletions packaging/tools/uninstall-taostools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ bin_link_dir="/usr/bin"
install_main_dir="/usr/local/taos"

# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'

csudo=""
Expand Down Expand Up @@ -72,7 +69,7 @@ function uninstall_taostools() {
uninstall_libtaosws

echo
echo -e "\033[44;32;1m${taosName} tools is uninstalled successfully!${NC}"
echo -e "${GREEN}${taosName} tools is uninstalled successfully!${NC}"
}

## ==============================Main program starts from here============================
Expand Down