preinst 1.1 KB
Newer Older
wafwerar's avatar
wafwerar 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#!/bin/bash

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

# 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

# there can not libtaos.so*, otherwise ln -s  error
${csudo}rm -f ${install_main_dir}/driver/libtaos*   || :