]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/triggers.systemd.in
Merge pull request #13365 from keszybz/fix-commits-from-pr-13246
[thirdparty/systemd.git] / src / core / triggers.systemd.in
1 # -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
2 # SPDX-License-Identifier: LGPL-2.1+
3 #
4 # This file is part of systemd.
5 # Copyright © 2018 Neal Gompa
6
7 # The contents of this are an example to be copied into systemd.spec.
8 #
9 # Minimum rpm version supported: 4.13.0
10
11 %transfiletriggerin -P 900900 -p <lua> -- @systemunitdir@ /etc/systemd/system
12 -- This script will run after any package is initially installed or
13 -- upgraded. We care about the case where a package is initially
14 -- installed, because other cases are covered by the *un scriptlets,
15 -- so sometimes we will reload needlessly.
16
17 if posix.access("/run/systemd/system") then
18 pid = posix.fork()
19 if pid == 0 then
20 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
21 elseif pid > 0 then
22 posix.wait(pid)
23 end
24 end
25
26 %transfiletriggerun -p <lua> -- @systemunitdir@ /etc/systemd/system
27 -- On removal, we need to run daemon-reload after any units have been
28 -- removed. %transfiletriggerpostun would be ideal, but it does not get
29 -- executed for some reason.
30 -- On upgrade, we need to run daemon-reload after any new unit files
31 -- have been installed, but before %postun scripts in packages get
32 -- executed. %transfiletriggerun gets the right list of files
33 -- but it is invoked too early (before changes happen).
34 -- %filetriggerpostun happens at the right time, but it fires for
35 -- every package.
36 -- To execute the reload at the right time, we create a state
37 -- file in %transfiletriggerun and execute the daemon-reload in
38 -- the first %filetriggerpostun.
39
40 if posix.access("/run/systemd/system") then
41 posix.mkdir("%{_localstatedir}/lib")
42 posix.mkdir("%{_localstatedir}/lib/rpm-state")
43 posix.mkdir("%{_localstatedir}/lib/rpm-state/systemd")
44 io.open("%{_localstatedir}/lib/rpm-state/systemd/needs-reload", "w")
45 end
46
47 %filetriggerpostun -P 1000100 -p <lua> -- @systemunitdir@ /etc/systemd/system
48 if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
49 posix.unlink("%{_localstatedir}/lib/rpm-state/systemd/needs-reload")
50 posix.rmdir("%{_localstatedir}/lib/rpm-state/systemd")
51 pid = posix.fork()
52 if pid == 0 then
53 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
54 elseif pid > 0 then
55 posix.wait(pid)
56 end
57 end
58
59 %transfiletriggerin -P 100700 -p <lua> -- @sysusersdir@
60 -- This script will process files installed in @sysusersdir@ to create
61 -- specified users automatically. The priority is set such that it
62 -- will run before the tmpfiles file trigger.
63 if posix.access("/run/systemd/system") then
64 pid = posix.fork()
65 if pid == 0 then
66 assert(posix.exec("%{_bindir}/systemd-sysusers"))
67 elseif pid > 0 then
68 posix.wait(pid)
69 end
70 end
71
72 %transfiletriggerin -P 100500 -p <lua> -- @tmpfilesdir@
73 -- This script will process files installed in @tmpfilesdir@ to create
74 -- tmpfiles automatically. The priority is set such that it will run
75 -- after the sysusers file trigger, but before any other triggers.
76 if posix.access("/run/systemd/system") then
77 pid = posix.fork()
78 if pid == 0 then
79 assert(posix.exec("%{_bindir}/systemd-tmpfiles", "--create"))
80 elseif pid > 0 then
81 posix.wait(pid)
82 end
83 end
84
85 %transfiletriggerin -p <lua> -- @udevhwdbdir@
86 -- This script will automatically invoke hwdb update if files have been
87 -- installed or updated in @udevhwdbdir@.
88 if posix.access("/run/systemd/system") then
89 pid = posix.fork()
90 if pid == 0 then
91 assert(posix.exec("%{_bindir}/systemd-hwdb", "update"))
92 elseif pid > 0 then
93 posix.wait(pid)
94 end
95 end
96
97 %transfiletriggerin -p <lua> -- @catalogdir@
98 -- This script will automatically invoke journal catalog update if files
99 -- have been installed or updated in @catalogdir@.
100 if posix.access("/run/systemd/system") then
101 pid = posix.fork()
102 if pid == 0 then
103 assert(posix.exec("%{_bindir}/journalctl", "--update-catalog"))
104 elseif pid > 0 then
105 posix.wait(pid)
106 end
107 end
108
109 %transfiletriggerin -p <lua> -- @udevrulesdir@
110 -- This script will automatically update udev with new rules if files
111 -- have been installed or updated in @udevrulesdir@.
112 if posix.access("/run/systemd/system") then
113 pid = posix.fork()
114 if pid == 0 then
115 assert(posix.exec("%{_bindir}/udevadm", "control", "--reload"))
116 elseif pid > 0 then
117 posix.wait(pid)
118 end
119 end
120
121 %transfiletriggerin -p <lua> -- @sysctldir@
122 -- This script will automatically apply sysctl rules if files have been
123 -- installed or updated in @sysctldir@.
124 if posix.access("/run/systemd/system") then
125 pid = posix.fork()
126 if pid == 0 then
127 assert(posix.exec("@rootlibexecdir@/systemd-sysctl"))
128 elseif pid > 0 then
129 posix.wait(pid)
130 end
131 end
132
133 %transfiletriggerin -p <lua> -- @binfmtdir@
134 -- This script will automatically apply binfmt rules if files have been
135 -- installed or updated in @binfmtdir@.
136 if posix.access("/run/systemd/system") then
137 pid = posix.fork()
138 if pid == 0 then
139 assert(posix.exec("@rootlibexecdir@/systemd-binfmt"))
140 elseif pid > 0 then
141 posix.wait(pid)
142 end
143 end