[Modify the use of sudo commands]

This commit is contained in:
plum-lihui 2019-07-19 15:39:15 +08:00
parent 4db1f9fa22
commit 38e7275be0
1 changed files with 8 additions and 3 deletions

View File

@ -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