preinst 822 字节
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 || :
H
[NONE]  
huili 已提交
12
    elif $(which insserv &> /dev/null); then
P
plum-lihui 已提交
13
        ${csudo} service taosd stop || :
H
[NONE]  
huili 已提交
14 15 16
    else
        pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}')
        ${csudo} kill -9 ${pid}   || :
H
hzcheng 已提交
17 18 19 20 21 22 23 24 25
    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 ${cfg_install_dir}/taos.cfg ]; then
P
plum-lihui 已提交
26
    ${csudo} rm -f ${install_main_dir}/cfg/taos.cfg   || :
H
[NONE]  
huili 已提交
27
fi
H
hzcheng 已提交
28

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