From 04e14b4c865f17966404d9fe12cc977e9460174e Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 19 Jan 2023 20:53:31 +0800 Subject: [PATCH] fix: install script detect if rpm/deb installed (#19648) * fix: install.sh to remove exist rpm * fix: install.sh to remove exist rpm * fix: refine packaging/tools/install.sh * fix: silient if no exist rpm * fix: dpkg remove exist deb --- packaging/tools/install.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 2a078b5eab..4be179b04d 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -743,6 +743,34 @@ function is_version_compatible() { esac } +deb_erase() { + confirm="" + while [ "" == "${confirm}" ]; do + echo -e -n "${RED}Exist tdengine deb detected, do you want to remove it? [yes|no] ${NC}:" + read confirm + if [ "yes" == "$confirm" ]; then + ${csudo}dpkg --remove tdengine ||: + break + elif [ "no" == "$confirm" ]; then + break + fi + done +} + +rpm_erase() { + confirm="" + while [ "" == "${confirm}" ]; do + echo -e -n "${RED}Exist tdengine rpm detected, do you want to remove it? [yes|no] ${NC}:" + read confirm + if [ "yes" == "$confirm" ]; then + ${csudo}rpm -e tdengine ||: + break + elif [ "no" == "$confirm" ]; then + break + fi + done +} + function updateProduct() { # Check if version compatible if ! is_version_compatible; then @@ -755,6 +783,13 @@ function updateProduct() { echo "File ${tarName} does not exist" exit 1 fi + + if echo $osinfo | grep -qwi "centos"; then + rpm -q tdengine 2>&1 > /dev/null && rpm_erase tdengine ||: + elif echo $osinfo | grep -qwi "ubuntu"; then + dpkg -l tdengine 2>&1 > /dev/null && deb_erase tdengine ||: + fi + tar -zxf ${tarName} install_jemalloc -- GitLab