]>
Commit | Line | Data |
---|---|---|
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. | |
96b2fb93 | 5 | # Copyright © 2018 Neal Gompa |
873e4133 ZJS |
6 | |
7 | # The contents of this are an example to be copied into systemd.spec. | |
af640dca ZJS |
8 | # |
9 | # Minimum rpm version supported: 4.13.0 | |
873e4133 | 10 | |
12dde791 ZJS |
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. | |
b7cf9ac0 | 16 | |
13749f54 ZJS |
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 | |
12dde791 | 24 | end |
873e4133 | 25 | |
12dde791 ZJS |
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. | |
b7cf9ac0 | 39 | |
13749f54 ZJS |
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 | |
b7cf9ac0 | 46 | |
12dde791 ZJS |
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 | |
32a00a9c NG |
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 | ||
694d5765 | 72 | %transfiletriggerin -P 100500 -p <lua> -- @tmpfilesdir@ |
32a00a9c NG |
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 | ||
694d5765 | 85 | %transfiletriggerin -p <lua> -- @udevhwdbdir@ |
32a00a9c NG |
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 | ||
694d5765 | 97 | %transfiletriggerin -p <lua> -- @catalogdir@ |
32a00a9c NG |
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 | ||
694d5765 | 109 | %transfiletriggerin -p <lua> -- @udevrulesdir@ |
32a00a9c NG |
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 | ||
694d5765 | 121 | %transfiletriggerin -p <lua> -- @sysctldir@ |
32a00a9c NG |
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 | ||
694d5765 | 133 | %transfiletriggerin -p <lua> -- @binfmtdir@ |
32a00a9c NG |
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 |