提交 e06f2444 编写于 作者: P plum-lihui

[Modify the use of sudo commands]

上级 2a36659e
...@@ -76,12 +76,17 @@ function is_using_systemd() { ...@@ -76,12 +76,17 @@ function is_using_systemd() {
fi fi
} }
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
# 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
...@@ -89,20 +94,28 @@ fi ...@@ -89,20 +94,28 @@ fi
# if taos.cfg already softlink, remove it # if taos.cfg already softlink, remove it
if [ -f %{cfg_install_dir}/taos.cfg ]; then if [ -f %{cfg_install_dir}/taos.cfg ]; then
sudo rm -f %{homepath}/cfg/taos.cfg || : ${csudo} rm -f %{homepath}/cfg/taos.cfg || :
fi fi
#Scripts executed after installation #Scripts executed after installation
%post %post
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
cd %{homepath}/script cd %{homepath}/script
sudo ./post.sh ${csudo} ./post.sh
# Scripts executed before uninstall # Scripts executed before uninstall
%preun %preun
csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
# only remove package to call preun.sh, not but update(2) # only remove package to call preun.sh, not but update(2)
if [ $1 -eq 0 ];then if [ $1 -eq 0 ];then
cd %{homepath}/script cd %{homepath}/script
sudo ./preun.sh ${csudo} ./preun.sh
fi fi
# Scripts executed after uninstall # Scripts executed after uninstall
...@@ -110,14 +123,17 @@ fi ...@@ -110,14 +123,17 @@ fi
# clean build dir # clean build dir
%clean %clean
rm -rf %{buildroot} csudo=""
if command -v sudo > /dev/null; then
csudo="sudo"
fi
${csudo} rm -rf %{buildroot}
#Specify the files to be packaged #Specify the files to be packaged
%files %files
/* /*
#%doc #%doc
#Setting default permissions #Setting default permissions
%defattr (-,root,root,0755) %defattr (-,root,root,0755)
#%{prefix} #%{prefix}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册