1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

Add more file triggers to handle more aspects of systemd (#8090)

For quite a while now, there have been file triggers to handle
automatically setting up service units in upstream systemd. However,
most of the actions being done by these macros upon files can be set up
as RPM file triggers.

In fact, in Mageia, we had been doing this for most of these. In particular,
we have file triggers in place for sysusers, tmpfiles, hwdb, and the journal.

This change adds Lua versions of the original file triggers used in Mageia,
based on the existing Lua-based file triggers for service units.

In addition, we can also have useful file triggers for udev rules, sysctl
directives, and binfmt directives. These are based on the other existing
file triggers.
This commit is contained in:
Neal Gompa (ニール・ゴンパ) 2018-02-06 04:11:36 -05:00 committed by Zbigniew Jędrzejewski-Szmek
parent 9207564756
commit 32a00a9c09
2 changed files with 90 additions and 9 deletions

View File

@ -84,17 +84,11 @@ fi \
%systemd_user_postun_with_restart() %{nil}
%udev_hwdb_update() \
systemd-hwdb update >/dev/null 2>&1 || : \
%{nil}
%udev_hwdb_update() %{nil}
%udev_rules_update() \
udevadm control --reload >/dev/null 2>&1 || : \
%{nil}
%udev_rules_update() %{nil}
%journal_catalog_update() \
journalctl --update-catalog >/dev/null 2>&1 || : \
%{nil}
%journal_catalog_update() %{nil}
%tmpfiles_create() \
systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \

View File

@ -4,6 +4,7 @@
# This file is part of systemd.
#
# Copyright 2015 Zbigniew Jędrzejewski-Szmek
# Copyright 2018 Neal Gompa
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
@ -69,3 +70,89 @@ if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
posix.wait(pid)
end
end
%transfiletriggerin -P 100700 -p <lua> -- @sysusersdir@
-- This script will process files installed in @sysusersdir@ to create
-- specified users automatically. The priority is set such that it
-- will run before the tmpfiles file trigger.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("%{_bindir}/systemd-sysusers"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -P 100500 -- @tmpfilesdir@
-- This script will process files installed in @tmpfilesdir@ to create
-- tmpfiles automatically. The priority is set such that it will run
-- after the sysusers file trigger, but before any other triggers.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("%{_bindir}/systemd-tmpfiles", "--create"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -- @udevhwdbdir@
-- This script will automatically invoke hwdb update if files have been
-- installed or updated in @udevhwdbdir@.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("%{_bindir}/systemd-hwdb", "update"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -- @catalogdir@
-- This script will automatically invoke journal catalog update if files
-- have been installed or updated in @catalogdir@.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("%{_bindir}/journalctl", "--update-catalog"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -- @udevrulesdir@
-- This script will automatically update udev with new rules if files
-- have been installed or updated in @udevrulesdir@.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("%{_bindir}/udevadm", "control", "--reload"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -- @sysctldir@
-- This script will automatically apply sysctl rules if files have been
-- installed or updated in @sysctldir@.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("@rootlibexecdir@/systemd-sysctl"))
elseif pid > 0 then
posix.wait(pid)
end
end
%transfiletriggerin -- @binfmtdir@
-- This script will automatically apply binfmt rules if files have been
-- installed or updated in @binfmtdir@.
if posix.access("/run/systemd/system") then
pid = posix.fork()
if pid == 0 then
assert(posix.exec("@rootlibexecdir@/systemd-binfmt"))
elseif pid > 0 then
posix.wait(pid)
end
end