* [gentoo-dev] [PATCH 0/1] systemd.eclass: add systemd_install_dropin
@ 2023-09-27 15:20 Florian Schmaus
2023-09-27 15:20 ` [gentoo-dev] [PATCH 1/1] " Florian Schmaus
0 siblings, 1 reply; 2+ messages in thread
From: Florian Schmaus @ 2023-09-27 15:20 UTC (permalink / raw
To: gentoo-dev, systemd; +Cc: Florian Schmaus
PR at https://github.com/gentoo/gentoo/pull/33089
Florian Schmaus (1):
systemd.eclass: add systemd_install_dropin
eclass/systemd.eclass | 44 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
--
2.41.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gentoo-dev] [PATCH 1/1] systemd.eclass: add systemd_install_dropin
2023-09-27 15:20 [gentoo-dev] [PATCH 0/1] systemd.eclass: add systemd_install_dropin Florian Schmaus
@ 2023-09-27 15:20 ` Florian Schmaus
0 siblings, 0 replies; 2+ messages in thread
From: Florian Schmaus @ 2023-09-27 15:20 UTC (permalink / raw
To: gentoo-dev, systemd; +Cc: Florian Schmaus
Closes: https://bugs.gentoo.org/876658
Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
eclass/systemd.eclass | 44 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index fbed387e0ca0..03d6a82fd310 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -1,4 +1,4 @@
-# Copyright 2011-2022 Gentoo Authors
+# Copyright 2011-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: systemd.eclass
@@ -227,6 +227,48 @@ systemd_install_serviced() {
)
}
+# @FUNCTION: systemd_install_dropin
+# @USAGE: [--user] <unit> <conf-file>
+# @DESCRIPTION:
+# Install <conf-file> as the dropin file <unit>.d/00gentoo.conf,
+# overriding the settings of <unit>.
+# Defaults to system unit dropins, unless --user is provided,
+# which causes the dropin to be installed for user units.
+# The required argument <conf-file> may be '-', in which case the
+# file is read from stdin and <unit> must also be specified.
+# @EXAMPLE:
+# systemd_install_dropin foo.service "${FILESDIR}/foo.service.conf"
+# systemd_install_dropin foo.service - <<-EOF
+# [Service]
+# RestartSec=120
+# EOF
+systemd_install_dropin() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local basedir
+ if [[ $# -ge 1 ]] && [[ $1 == "--user" ]]; then
+ basedir=$(_systemd_unprefix systemd_get_userunitdir)
+ shift 1
+ else
+ basedir=$(_systemd_unprefix systemd_get_systemunitdir)
+ fi
+
+ local unit=${1}
+ local src=${2}
+
+ [[ ${unit} ]] || die "No unit specified"
+ [[ ${src} ]] || die "No conf file specified"
+
+ # avoid potentially common mistake
+ [[ ${unit} == *.d ]] && die "Unit ${unit} must not have .d suffix"
+
+ (
+ insopts -m 0644
+ insinto "${basedir}/${unit}".d
+ newins "${src}" 00gentoo.conf
+ )
+}
+
# @FUNCTION: systemd_enable_service
# @USAGE: <target> <service>
# @DESCRIPTION:
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-27 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-27 15:20 [gentoo-dev] [PATCH 0/1] systemd.eclass: add systemd_install_dropin Florian Schmaus
2023-09-27 15:20 ` [gentoo-dev] [PATCH 1/1] " Florian Schmaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox