From 38e7275be06ca27aadfe05e65041df420208f88c Mon Sep 17 00:00:00 2001 From: plum-lihui <2849823933@qq.com> Date: Fri, 19 Jul 2019 15:39:15 +0800 Subject: [PATCH] [Modify the use of sudo commands] --- packaging/deb/DEBIAN/preinst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packaging/deb/DEBIAN/preinst b/packaging/deb/DEBIAN/preinst index 88b76568df..d31129ba2c 100644 --- a/packaging/deb/DEBIAN/preinst +++ b/packaging/deb/DEBIAN/preinst @@ -1,5 +1,10 @@ #!/bin/bash +csudo="" +if command -v sudo > /dev/null; then + csudo="sudo" +fi + function is_using_systemd() { if pidof systemd &> /dev/null; then return 0 @@ -11,9 +16,9 @@ function is_using_systemd() { # Stop the service if running if pidof taosd &> /dev/null; then if is_using_systemd; then - sudo systemctl stop taosd || : + ${csudo} systemctl stop taosd || : else - sudo service taosd stop || : + ${csudo} service taosd stop || : fi echo "Stop taosd service success!" sleep 1 @@ -23,6 +28,6 @@ fi cfg_install_dir="/etc/taos" install_main_dir="/usr/local/taos" if [ -f ${cfg_install_dir}/taos.cfg ]; then - sudo rm -f ${install_main_dir}/cfg/taos.cfg || : + ${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || : fi -- GitLab