[Modify the use of sudo commands]
This commit is contained in:
parent
4db1f9fa22
commit
38e7275be0
|
@ -1,5 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
csudo=""
|
||||||
|
if command -v sudo > /dev/null; then
|
||||||
|
csudo="sudo"
|
||||||
|
fi
|
||||||
|
|
||||||
function is_using_systemd() {
|
function is_using_systemd() {
|
||||||
if pidof systemd &> /dev/null; then
|
if pidof systemd &> /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
|
@ -11,9 +16,9 @@ function is_using_systemd() {
|
||||||
# Stop the service if running
|
# Stop the service if running
|
||||||
if pidof taosd &> /dev/null; then
|
if pidof taosd &> /dev/null; then
|
||||||
if is_using_systemd; then
|
if is_using_systemd; then
|
||||||
sudo systemctl stop taosd || :
|
${csudo} systemctl stop taosd || :
|
||||||
else
|
else
|
||||||
sudo service taosd stop || :
|
${csudo} service taosd stop || :
|
||||||
fi
|
fi
|
||||||
echo "Stop taosd service success!"
|
echo "Stop taosd service success!"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -23,6 +28,6 @@ fi
|
||||||
cfg_install_dir="/etc/taos"
|
cfg_install_dir="/etc/taos"
|
||||||
install_main_dir="/usr/local/taos"
|
install_main_dir="/usr/local/taos"
|
||||||
if [ -f ${cfg_install_dir}/taos.cfg ]; then
|
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
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue