diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 472d853637d8f39f02de2f872555794e3e026d5b..b313f90e90eeb6c4c29e70a6e276aa5e49b3e786 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -11,6 +11,8 @@ if pidof taosd &> /dev/null; then ${csudo} systemctl stop taosd || : elif $(which insserv &> /dev/null); then ${csudo} service taosd stop || : + elif $(which update-rc.d &> /dev/null); then + ${csudo} service taosd stop || : else pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') ${csudo} kill -9 ${pid} || : diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index 7b0a1afd6e75b68719a190848e0c50b2c170ef0d..c858f01d8a46b8096a09cbc533e5ab68043de688 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -70,14 +70,6 @@ cp -r %{_compiledir}/../tests/examples/* %{buildroot}%{homepath}/exam #Scripts executed before installation %pre -function is_using_systemd() { - if pidof systemd &> /dev/null; then - return 0 - else - return 1 - fi -} - csudo="" if command -v sudo > /dev/null; then csudo="sudo" @@ -85,10 +77,15 @@ fi # Stop the service if running if pidof taosd &> /dev/null; then - if is_using_systemd; then + if pidof systemd &> /dev/null; then ${csudo} systemctl stop taosd || : - else + elif $(which insserv &> /dev/null); then ${csudo} service taosd stop || : + elif $(which update-rc.d &> /dev/null); then + ${csudo} service taosd stop || : + else + pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') + ${csudo} kill -9 ${pid} || : fi echo "Stop taosd service success!" sleep 1 diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 7dd64306602ee1c4d28a6622f3f96d7ed37377cf..9e1878365737d614369d536932ba0b00918d2a4f 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -38,26 +38,26 @@ if command -v sudo > /dev/null; then csudo="sudo" fi +initd_mod=0 service_mod=2 if pidof systemd &> /dev/null; then service_mod=0 +elif $(which insserv &> /dev/null); then + service_mod=1 + initd_mod=1 + service_config_dir="/etc/init.d" elif $(which update-rc.d &> /dev/null); then service_mod=1 + initd_mod=2 service_config_dir="/etc/init.d" else service_mod=2 fi function kill_taosd() { - ${csudo} pkill -f taosd || : -} - -function is_using_systemd() { - if pidof systemd &> /dev/null; then - return 0 - else - return 1 - fi +# ${csudo} pkill -f taosd || : + pid=$(ps -ef | grep "taosd" | grep -v "grep" | awk '{print $2}') + ${csudo} kill -9 ${pid} || : } function install_include() { @@ -103,12 +103,18 @@ function install_config() { function clean_service_on_sysvinit() { restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" - #if pidof taosd &> /dev/null; then - # ${csudo} service taosd stop || : - #fi + if pidof taosd &> /dev/null; then + ${csudo} service taosd stop || : + fi ${csudo} sed -i "\|${restart_config_str}|d" /etc/inittab || : ${csudo} rm -f ${service_config_dir}/taosd || : - ${csudo} update-rc.d -f taosd remove || : + + if ((${initd_mod}==1)); then + ${csudo} grep -q -F "taos" /etc/inittab && ${csudo} insserv -r taosd || : + elif ((${initd_mod}==2)); then + ${csudo} grep -q -F "taos" /etc/inittab && ${csudo} update-rc.d -f taosd remove || : + fi +# ${csudo} update-rc.d -f taosd remove || : ${csudo} init q || : }