preinst 977 字节
Newer Older
H
hzcheng 已提交
1 2
#!/bin/bash

P
plum-lihui 已提交
3 4 5 6 7
csudo=""
if command -v sudo > /dev/null; then
    csudo="sudo"
fi

H
hzcheng 已提交
8 9
# Stop the service if running
if pidof taosd &> /dev/null; then
H
[NONE]  
huili 已提交
10
    if pidof systemd &> /dev/null; then
P
plum-lihui 已提交
11
        ${csudo} systemctl stop taosd || :
L
lihui 已提交
12
    elif $(which service  &> /dev/null); then
H
[NONE]  
huili 已提交
13
        ${csudo} service taosd stop || :
H
[NONE]  
huili 已提交
14 15
    else
        pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
L
lihui 已提交
16 17 18
        if [ -n "$pid" ]; then
           ${csudo} kill -9 $pid   || :
        fi
H
hzcheng 已提交
19 20 21 22 23 24 25 26
    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"
27
if [ -f "${install_main_dir}/taos.cfg" ]; then
P
plum-lihui 已提交
28
    ${csudo} rm -f ${install_main_dir}/cfg/taos.cfg   || :
H
[NONE]  
huili 已提交
29
fi
H
hzcheng 已提交
30

31 32 33 34
if [ -f "${install_main_dir}/blm.toml" ]; then
    ${csudo} rm -f ${install_main_dir}/cfg/blm.toml     || :
fi

H
[NONE]  
huili 已提交
35
# there can not libtaos.so*, otherwise ln -s  error
36
${csudo} rm -f ${install_main_dir}/driver/libtaos*   || :