diff options
-rw-r--r-- | aops-mcp.spec | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/aops-mcp.spec b/aops-mcp.spec index 6e88197..6e67cb0 100644 --- a/aops-mcp.spec +++ b/aops-mcp.spec @@ -54,15 +54,24 @@ ln -s /opt/%{name}/venv/bin/aops-mcp %{buildroot}%{_bindir}/aops-mcp %post # systemd 配置 -%systemd_post aops-mcp.service +if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then + # Initial installation + /usr/lib/systemd/systemd-update-helper install-system-units aops-mcp.service || : +fi %preun # 卸载前停止服务 -%systemd_preun aops-mcp.service +if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then + # Package removal, not upgrade + /usr/lib/systemd/systemd-update-helper remove-system-units aops-mcp.service || : +fi %postun # 清理配置 -%systemd_postun_with_restart aops-mcp.service +if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then + # Package upgrade, not uninstall + /usr/bin/systemctl try-restart aops-mcp.service || : +fi %files %dir /opt/%{name} |