preinst 2.6 KB
Newer Older
wafwerar's avatar
wafwerar 已提交
1 2
#!/bin/bash

wafwerar's avatar
wafwerar 已提交
3 4 5 6 7
if [ -f /var/lib/taos/dnode/dnodeCfg.json ]; then
  echo -e "The default data directory \033[41;37m/var/lib/taos\033[0m contains old data of tdengine 2.x, please clear it before installing!"
  exit 1
fi

wafwerar's avatar
wafwerar 已提交
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi

# Stop the service if running
if pidof taosd &> /dev/null; then
    if pidof systemd &> /dev/null; then
        ${csudo}systemctl stop taosd || :
    elif $(which service  &> /dev/null); then
        ${csudo}service taosd stop || :
    else
        pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
        if [ -n "$pid" ]; then
           ${csudo}kill -9 $pid   || :
        fi
    fi
    echo "Stop taosd service success!"
    sleep 1
fi

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
# Stop adapter service if running
if pidof taosadapter &> /dev/null; then
    if pidof systemd &> /dev/null; then
        ${csudo}systemctl stop taosadapter || :
    elif $(which service  &> /dev/null); then
        ${csudo}service taosadapter stop || :
    else
        pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}')
        if [ -n "$pid" ]; then
           ${csudo}kill -9 $pid   || :
        fi
    fi
    echo "Stop taosadapter service success!"
    sleep 1
fi

# Stop keeper service if running
if pidof taoskeeper &> /dev/null; then
    if pidof systemd &> /dev/null; then
        ${csudo}systemctl stop taoskeeper || :
    elif $(which service  &> /dev/null); then
        ${csudo}service taoskeeper stop || :
    else
        pid=$(ps -ef | grep "taoskeeper" | grep -v "grep" | awk '{print $2}')
        if [ -n "$pid" ]; then
           ${csudo}kill -9 $pid   || :
        fi
    fi
    echo "Stop taoskeeper service success!"
    sleep 1
fi

wafwerar's avatar
wafwerar 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
# if taos.cfg already softlink, remove it
cfg_install_dir="/etc/taos"
install_main_dir="/usr/local/taos"
if [ -f "${install_main_dir}/taos.cfg" ]; then
    ${csudo}rm -f ${install_main_dir}/cfg/taos.cfg   || :
fi

if [ -f "${install_main_dir}/taosadapter.toml" ]; then
    ${csudo}rm -f ${install_main_dir}/cfg/taosadapter.toml     || :
fi

if [ -f "${install_main_dir}/taosadapter.service" ]; then
    ${csudo}rm -f ${install_main_dir}/cfg/taosadapter.service || :
fi

76 77 78 79 80
if [ -f "${install_main_dir}/taoskeeper.toml" ]; then
    ${csudo}rm -f ${install_main_dir}/cfg/taoskeeper.toml     || :
fi


wafwerar's avatar
wafwerar 已提交
81
# there can not libtaos.so*, otherwise ln -s  error
82
${csudo}rm -f ${install_main_dir}/driver/libtaos.*   || :
83
[ -f ${install_main_dir}/driver/librocksdb.* ] && ${csudo}rm -f ${install_main_dir}/driver/librocksdb.*  || :
84
[ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}rm -f ${install_main_dir}/driver/libtaosws.so   || :