Skip to content

Commit

Permalink
fix(rpm): Delay Naemon restart until posttrans
Browse files Browse the repository at this point in the history
The posttrans scriptlet executes after the RPM transaction has
concluded, i.e. when all packages have been installed or upgraded.
Delaying the Naemon restart until posttrans prevents API compatibility
issues when naemon-core upgrades before naemon-livestatus. See
#454.

Note that it is not possible to infer the RPM operation (install or
upgrade) from the posttrans scriptlet argument, since they are the same:
https://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets#Syntax
This should not cause any problems since the scriptlet only restarts
Naemon if it was already running. In other words, it won't cause Naemon
to start immediately after installation.
  • Loading branch information
imre-sidn authored and sni committed Mar 2, 2024
1 parent e26899b commit 3e07412
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions naemon-core.spec
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,8 @@ fi
%post
case "$*" in
2)
# Upgrading so try and restart if already running
# For systemctl systems we need to reload the configs
# becaues it'll complain if we just installed a new
# init script
%if %{?_unitdir:1}0
systemctl daemon-reload &>/dev/null || true
systemctl condrestart naemon.service &>/dev/null || true
%else
/etc/init.d/naemon condrestart &>/dev/null || true
%endif
# Upgrade, don't do anything
# Restarts are handled in posttrans
;;
1)
# install example conf.d only once on the first installation
Expand Down Expand Up @@ -285,6 +277,18 @@ case "$*" in
esac
exit 0

%posttrans
# try and restart if already running
# For systemctl systems we need to reload the configs
# because it'll complain if we just installed a new
# init script
%if %{?_unitdir:1}0
systemctl daemon-reload &>/dev/null || true
systemctl condrestart naemon.service &>/dev/null || true
%else
/etc/init.d/naemon condrestart &>/dev/null || true
%endif
%files
Expand Down

0 comments on commit 3e07412

Please sign in to comment.