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