From 915807dc5391f1e063581a6413e79527dd62d3e4 Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Wed, 4 Sep 2024 11:22:33 +0800 Subject: [PATCH] opt: rpm support environment parameter to DB install or upgrade --- rpmbuild/SPECS/omc.spec | 62 ++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/rpmbuild/SPECS/omc.spec b/rpmbuild/SPECS/omc.spec index 71b4c1a..de43650 100644 --- a/rpmbuild/SPECS/omc.spec +++ b/rpmbuild/SPECS/omc.spec @@ -118,14 +118,36 @@ systemctl enable restagent.service systemctl enable crontask.service systemctl enable sshsvc.service systemctl enable captrace.service + +# read environment parameter and to do +if [ "$M_PARAM" = "install" -o "$M_PARAM" = "upgrade" ]; then + echo "M parameter: $M_PARAM" + if [ -n "$C_PARAM" ]; then + echo "C parameter: $C_PARAM" + ${OMCRootDir}/bin/setomc.sh -m $M_PARAM -c $C_PARAM + else + ${OMCRootDir}/bin/setomc.sh -m $M_PARAM + fi + # exit while failed to run setomc.sh + if [ $? -ne 0 ]; then + echo "setomc.sh execution failed. Exiting." + exit 1 + fi +fi + +echo -n "Stopping OMC service ... " systemctl stop restagent.service systemctl stop crontask.service systemctl stop sshsvc.service systemctl stop captrace.service +echo "done" + +echo -n "Starting OMC service ... " systemctl start captrace.service systemctl start sshsvc.service systemctl start crontask.service systemctl start restagent.service +echo "done" # 卸载时执行 %postun @@ -148,27 +170,27 @@ done firewall-cmd --reload if [ "$1" = "0" ] ; then -sudo systemctl stop restagent.service -sudo systemctl stop crontask.service -sudo systemctl stop sshsvc.service -sudo systemctl stop captrace.service -#rm -rf /usr/local/omc -rm -rf /etc/nginx/conf.d/omc.conf -sudo systemctl disable restagent.service -sudo systemctl disable crontask.service -sudo systemctl disable sshsvc.service -sudo systemctl disable captrace.service -sudo systemctl daemon-reload + sudo systemctl stop restagent.service + sudo systemctl stop crontask.service + sudo systemctl stop sshsvc.service + sudo systemctl stop captrace.service + #rm -rf /usr/local/omc + rm -rf /etc/nginx/conf.d/omc.conf + sudo systemctl disable restagent.service + sudo systemctl disable crontask.service + sudo systemctl disable sshsvc.service + sudo systemctl disable captrace.service + sudo systemctl daemon-reload else -sudo systemctl daemon-reload -sudo systemctl stop restagent.service -sudo systemctl stop crontask.service -sudo systemctl stop sshsvc.service -sudo systemctl stop captrace.service -sudo systemctl start crontask.service -sudo systemctl start sshsvc.service -sudo systemctl start captrace.service -sudo systemctl start restagent.service + sudo systemctl daemon-reload + sudo systemctl stop restagent.service + sudo systemctl stop crontask.service + sudo systemctl stop sshsvc.service + sudo systemctl stop captrace.service + sudo systemctl start crontask.service + sudo systemctl start sshsvc.service + sudo systemctl start captrace.service + sudo systemctl start restagent.service fi # 规定那些文件必须放入安装程序中,如果没有就报错