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

wafwerar's avatar
wafwerar 已提交
3
if [ "$1"x = "abort-upgrade"x ]; then
wafwerar's avatar
wafwerar 已提交
4 5 6
  exit 0
fi

wafwerar's avatar
wafwerar 已提交
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
insmetaPath="/usr/local/taos/script"

csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo "
fi

${csudo}chmod -R 744 ${insmetaPath}  || :
#cd ${insmetaPath}
#${csudo}./preun.sh
if [ -f ${insmetaPath}/preun.sh ]; then
    cd ${insmetaPath}
    ${csudo}./preun.sh
else
    bin_link_dir="/usr/bin"
    lib_link_dir="/usr/lib"
    inc_link_dir="/usr/include"

    data_link_dir="/usr/local/taos/data"
    log_link_dir="/usr/local/taos/log"
    cfg_link_dir="/usr/local/taos/cfg"

    # Remove all links
    ${csudo}rm -f ${bin_link_dir}/taos       || :
    ${csudo}rm -f ${bin_link_dir}/taosd      || :
wafwerar's avatar
wafwerar 已提交
32
    ${csudo}rm -f ${bin_link_dir}/udfd       || :
wafwerar's avatar
wafwerar 已提交
33 34 35 36
    ${csudo}rm -f ${bin_link_dir}/taosadapter       || :
    ${csudo}rm -f ${bin_link_dir}/taosdemo   || :
    ${csudo}rm -f ${cfg_link_dir}/*          || :
    ${csudo}rm -f ${inc_link_dir}/taos.h     || :
37 38
    ${csudo}rm -f ${inc_link_dir}/taosdef.h     || :
    ${csudo}rm -f ${inc_link_dir}/taoserror.h     || :
39
    ${csudo}rm -f ${inc_link_dir}/taosudf.h     || :
40
    [ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h     || :
wafwerar's avatar
wafwerar 已提交
41
    ${csudo}rm -f ${lib_link_dir}/libtaos.*  || :
42
    [ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so  || :
wafwerar's avatar
wafwerar 已提交
43 44 45 46 47 48 49 50 51 52

    ${csudo}rm -f ${log_link_dir}            || :
    ${csudo}rm -f ${data_link_dir}           || :

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