mirror of https://gitee.com/openkylin/libvirt.git
spec: avoid repeated calls to systemd macros and binaries
The macro can take multiple arguments, and the calls are more efficient if done in one go. Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
This commit is contained in:
parent
8a4c84e540
commit
da0f94c2a9
|
@ -1257,31 +1257,35 @@ getent group libvirt >/dev/null || groupadd -r libvirt
|
|||
exit 0
|
||||
|
||||
%post daemon
|
||||
%global post_units \\\
|
||||
virtlockd.socket virtlockd-admin.socket \\\
|
||||
virtlogd.socket virtlogd-admin.socket \\\
|
||||
libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\
|
||||
libvirtd-tcp.socket libvirtd-tls.socket \\\
|
||||
libvirtd.service \\\
|
||||
libvirt-guests.service
|
||||
|
||||
%systemd_post virtlockd.socket virtlockd-admin.socket
|
||||
%systemd_post virtlogd.socket virtlogd-admin.socket
|
||||
%systemd_post libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
|
||||
%systemd_post libvirtd-tcp.socket libvirtd-tls.socket
|
||||
%systemd_post libvirtd.service
|
||||
%systemd_post libvirt-guests.service
|
||||
%systemd_post %post_units
|
||||
|
||||
# request daemon restart in posttrans
|
||||
mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || :
|
||||
touch %{_localstatedir}/lib/rpm-state/libvirt/restart || :
|
||||
|
||||
%preun daemon
|
||||
%systemd_preun libvirtd.service
|
||||
%systemd_preun libvirtd-tcp.socket libvirtd-tls.socket
|
||||
%systemd_preun libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket
|
||||
%systemd_preun virtlogd.socket virtlogd-admin.socket virtlogd.service
|
||||
%systemd_preun virtlockd.socket virtlockd-admin.socket virtlockd.service
|
||||
%systemd_preun libvirt-guests.service
|
||||
%global preun_units \\\
|
||||
libvirtd.service \\\
|
||||
libvirtd-tcp.socket libvirtd-tls.socket \\\
|
||||
libvirtd.socket libvirtd-ro.socket libvirtd-admin.socket \\\
|
||||
virtlogd.socket virtlogd-admin.socket virtlogd.service \\\
|
||||
virtlockd.socket virtlockd-admin.socket virtlockd.service \\\
|
||||
libvirt-guests.service
|
||||
|
||||
%systemd_preun %preun_units
|
||||
|
||||
%postun daemon
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
if [ $1 -ge 1 ] ; then
|
||||
/bin/systemctl reload-or-try-restart virtlockd.service >/dev/null 2>&1 || :
|
||||
/bin/systemctl reload-or-try-restart virtlogd.service >/dev/null 2>&1 || :
|
||||
/bin/systemctl reload-or-try-restart virtlockd.service virtlogd.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
%systemd_postun libvirt-guests.service
|
||||
|
||||
|
@ -1308,11 +1312,12 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
|
|||
# systemd socket activation, because switching things
|
||||
# might confuse mgmt tool like puppet/ansible that
|
||||
# expect the old style libvirtd
|
||||
/bin/systemctl mask libvirtd.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl mask libvirtd-ro.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl mask libvirtd-admin.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl mask libvirtd-tls.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl mask libvirtd-tcp.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl mask \
|
||||
libvirtd.socket \
|
||||
libvirtd-ro.socket \
|
||||
libvirtd-admin.socket \
|
||||
libvirtd-tls.socket \
|
||||
libvirtd-tcp.socket >/dev/null 2>&1 || :
|
||||
else
|
||||
# Old libvirtd owns the sockets and will delete them on
|
||||
# shutdown. Can't use a try-restart as libvirtd will simply
|
||||
|
@ -1324,9 +1329,10 @@ if [ -f %{_localstatedir}/lib/rpm-state/libvirt/restart ]; then
|
|||
then
|
||||
/bin/systemctl stop libvirtd.service >/dev/null 2>&1 || :
|
||||
|
||||
/bin/systemctl try-restart libvirtd.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl try-restart libvirtd-ro.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl try-restart libvirtd-admin.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl try-restart \
|
||||
libvirtd.socket \
|
||||
libvirtd-ro.socket \
|
||||
libvirtd-admin.socket >/dev/null 2>&1 || :
|
||||
|
||||
/bin/systemctl start libvirtd.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue