]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/core/triggers.systemd.in
shared: silence gcc warning (#7402)
[thirdparty/systemd.git] / src / core / triggers.systemd.in
CommitLineData
873e4133 1# -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
d9215cd8 2# SPDX-License-Identifier: LGPL-2.1+
873e4133
ZJS
3#
4# This file is part of systemd.
5#
6# Copyright 2015 Zbigniew Jędrzejewski-Szmek
7#
8# systemd is free software; you can redistribute it and/or modify it
9# under the terms of the GNU Lesser General Public License as published by
10# the Free Software Foundation; either version 2.1 of the License, or
11# (at your option) any later version.
12#
13# systemd is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# Lesser General Public License for more details.
17#
18# You should have received a copy of the GNU Lesser General Public License
19# along with systemd; If not, see <http://www.gnu.org/licenses/>.
20
21# The contents of this are an example to be copied into systemd.spec.
af640dca
ZJS
22#
23# Minimum rpm version supported: 4.13.0
873e4133 24
12dde791
ZJS
25%transfiletriggerin -P 900900 -p <lua> -- @systemunitdir@ /etc/systemd/system
26-- This script will run after any package is initially installed or
27-- upgraded. We care about the case where a package is initially
28-- installed, because other cases are covered by the *un scriptlets,
29-- so sometimes we will reload needlessly.
b7cf9ac0 30
13749f54
ZJS
31if posix.access("/run/systemd/system") then
32 pid = posix.fork()
33 if pid == 0 then
34 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
35 elseif pid > 0 then
36 posix.wait(pid)
37 end
12dde791 38end
873e4133 39
12dde791
ZJS
40%transfiletriggerun -p <lua> -- @systemunitdir@ /etc/systemd/system
41-- On removal, we need to run daemon-reload after any units have been
42-- removed. %transfiletriggerpostun would be ideal, but it does not get
43-- executed for some reason.
44-- On upgrade, we need to run daemon-reload after any new unit files
45-- have been installed, but before %postun scripts in packages get
46-- executed. %transfiletriggerun gets the right list of files
47-- but it is invoked too early (before changes happen).
48-- %filetriggerpostun happens at the right time, but it fires for
49-- every package.
50-- To execute the reload at the right time, we create a state
51-- file in %transfiletriggerun and execute the daemon-reload in
52-- the first %filetriggerpostun.
b7cf9ac0 53
13749f54
ZJS
54if posix.access("/run/systemd/system") then
55 posix.mkdir("%{_localstatedir}/lib")
56 posix.mkdir("%{_localstatedir}/lib/rpm-state")
57 posix.mkdir("%{_localstatedir}/lib/rpm-state/systemd")
58 io.open("%{_localstatedir}/lib/rpm-state/systemd/needs-reload", "w")
59end
b7cf9ac0 60
12dde791
ZJS
61%filetriggerpostun -P 1000100 -p <lua> -- @systemunitdir@ /etc/systemd/system
62if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
63 posix.unlink("%{_localstatedir}/lib/rpm-state/systemd/needs-reload")
64 posix.rmdir("%{_localstatedir}/lib/rpm-state/systemd")
65 pid = posix.fork()
66 if pid == 0 then
67 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
68 elseif pid > 0 then
69 posix.wait(pid)
70 end
71end