triggers.systemd.in revision b7cf9ac00afb10b5a2f63446babcf8d97111a636
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# This file is part of systemd.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Copyright 2015 Zbigniew Jędrzejewski-Szmek
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# systemd is free software; you can redistribute it and/or modify it
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# under the terms of the GNU Lesser General Public License as published by
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# the Free Software Foundation; either version 2.1 of the License, or
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# (at your option) any later version.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# systemd is distributed in the hope that it will be useful, but
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# WITHOUT ANY WARRANTY; without even the implied warranty of
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# Lesser General Public License for more details.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes#
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# You should have received a copy of the GNU Lesser General Public License
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# along with systemd; If not, see <http://www.gnu.org/licenses/>.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# The contents of this are an example to be copied into systemd.spec.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
ee4f2857570f20e369994ea71ad5928832cc64d8bnicholes# This will run after any package is initially installed or
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes# upgraded. We care about the case where a package is initially
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes# installed, because other cases are covered by the scriptlets below,
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes# so sometimes we will reload needlessly.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes%transfiletriggerin -- @systemunitdir@ /etc/systemd/system
bb2b38cd44b032118359afbc743efbea12f48e61bnicholessystemctl daemon-reload &>/dev/null || :
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# On removal, we need to run daemon-reload after any units have been
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# removed. %transfiletriggerpostun would be ideal, but it does not get
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# executed for some reason.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# On upgrade, we need to run daemon-reload after any new unit files
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# have been installed, but before %postun scripts in packages get
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# executed. %transfiletriggerun gets the right list of files
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# but it is invoked too early (before changes happen).
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# %filetriggerpostun happens at the right time, but it fires for
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# every package.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# To execute the reload at the right time, we create a state
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# file in %transfiletriggerun and execute the daemon-reload in
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes# the first %filetriggerpostun.
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes%transfiletriggerun -- @systemunitdir@ /etc/systemd/system
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesmkdir -p %{_localstatedir}/lib/rpm-state/systemd
bb2b38cd44b032118359afbc743efbea12f48e61bnicholestouch %{_localstatedir}/lib/rpm-state/systemd/needs-reload
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes%filetriggerpostun -- @systemunitdir@ /etc/systemd/system
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesif [ -e %{_localstatedir}/lib/rpm-state/systemd/needs-reload ]; then
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes rm %{_localstatedir}/lib/rpm-state/systemd/needs-reload || :
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes rmdir %{_localstatedir}/lib/rpm-state/systemd || :
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes systemctl daemon-reload || :
bb2b38cd44b032118359afbc743efbea12f48e61bnicholesfi
bb2b38cd44b032118359afbc743efbea12f48e61bnicholes