preinst 753 字节
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 10 11 12 13 14 15 16 17 18
function is_using_systemd() {
    if pidof systemd &> /dev/null; then
        return 0
    else
        return 1
    fi
}

# Stop the service if running
if pidof taosd &> /dev/null; then
    if is_using_systemd; then
P
plum-lihui 已提交
19
        ${csudo} systemctl stop taosd || :
H
hzcheng 已提交
20
    else
P
plum-lihui 已提交
21
        ${csudo} service taosd stop || :
H
hzcheng 已提交
22 23 24 25 26 27 28 29 30
    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 已提交
31
    ${csudo} rm -f ${install_main_dir}/cfg/taos.cfg   || :
H
hzcheng 已提交
32 33
fi    

H
huili 已提交
34 35 36
${csudo} dpkg -P tdengine   || :
${csudo} rm -f /var/lib/dpkg/info/tdengine*   || :