remove_client.sh 1.7 KB
Newer Older
L
lihui 已提交
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
#
# Script to stop the client and uninstall database, but retain the config and log files.
set -e
# set -x

RED='\033[0;31m'
GREEN='\033[1;32m'
NC='\033[0m'

Z
change  
zyyang 已提交
11 12 13 14
installDir="/usr/local/taos"
clientName="taos"
uninstallScript="rmtaos"

L
lihui 已提交
15
#install main path
Z
change  
zyyang 已提交
16
install_main_dir=${installDir}
L
lihui 已提交
17

Z
change  
zyyang 已提交
18 19
log_link_dir="${installDir}/log"
cfg_link_dir="${installDir}/cfg"
L
lihui 已提交
20 21
bin_link_dir="/usr/bin"
lib_link_dir="/usr/lib"
H
Hui Li 已提交
22
lib64_link_dir="/usr/lib64"
L
lihui 已提交
23 24 25
inc_link_dir="/usr/include"

csudo=""
Z
change  
zyyang 已提交
26 27
if command -v sudo >/dev/null; then
  csudo="sudo "
L
lihui 已提交
28 29 30
fi

function kill_client() {
Z
change  
zyyang 已提交
31 32
  if [ -n "$(pidof ${clientName})" ]; then
    ${csudo}kill -9 $pid || :
L
lihui 已提交
33 34 35 36
  fi
}

function clean_bin() {
Z
change  
zyyang 已提交
37 38 39 40
  # Remove link
  ${csudo}rm -f ${bin_link_dir}/${clientName} || :
  ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
  ${csudo}rm -f ${bin_link_dir}/set_core || :
L
lihui 已提交
41 42 43
}

function clean_lib() {
Z
change  
zyyang 已提交
44 45 46 47
  # Remove link
  ${csudo}rm -f ${lib_link_dir}/libtaos.* || :
  ${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
  #${csudo}rm -rf ${v15_java_app_dir}           || :
L
lihui 已提交
48 49 50
}

function clean_header() {
Z
change  
zyyang 已提交
51 52 53 54
  # Remove link
  ${csudo}rm -f ${inc_link_dir}/taos.h || :
  ${csudo}rm -f ${inc_link_dir}/taosdef.h || :
  ${csudo}rm -f ${inc_link_dir}/taoserror.h || :
L
lihui 已提交
55 56 57
}

function clean_config() {
Z
change  
zyyang 已提交
58 59
  # Remove link
  ${csudo}rm -f ${cfg_link_dir}/* || :
L
lihui 已提交
60 61 62
}

function clean_log() {
Z
change  
zyyang 已提交
63 64
  # Remove link
  ${csudo}rm -rf ${log_link_dir} || :
L
lihui 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
}

# Stop client.
kill_client
# Remove binary file and links
clean_bin
# Remove header file.
clean_header
# Remove lib file
clean_lib
# Remove link log directory
clean_log
# Remove link configuration file
clean_config

80
${csudo}rm -rf ${install_main_dir}
L
lihui 已提交
81 82

echo -e "${GREEN}TDengine client is removed successfully!${NC}"
Z
change  
zyyang 已提交
83
echo