public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH systemd.eclass] Introduce systemd_install_serviced().
@ 2013-09-08 11:12 Michał Górny
  2013-09-08 15:14 ` Gilles Dartiguelongue
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Michał Górny @ 2013-09-08 11:12 UTC (permalink / raw
  To: gentoo-dev; +Cc: systemd, Michał Górny

This function can be used to install service configuration templates.
Usage:

  systemd_install_serviced "${FILESDIR}"/foo.service.conf

or:

  systemd_install_serviced "${FILESDIR}"/barbaz foo.service

with the latter specifying related service name explicitly, former
expecting it to match ${basename%.conf}. The files are installed as:

  /etc/systemd/system/foo.service.d/00gentoo.conf

They should be commented out templates that users can use to customize
the service easily.
---
 gx86/eclass/systemd.eclass | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gx86/eclass/systemd.eclass b/gx86/eclass/systemd.eclass
index 4566631..1575b78 100644
--- a/gx86/eclass/systemd.eclass
+++ b/gx86/eclass/systemd.eclass
@@ -131,6 +131,32 @@ systemd_newunit() {
 	newins "${@}"
 }
 
+# @FUNCTION: systemd_install_serviced
+# @USAGE: <conf-file> [<service.d>]
+# @DESCRIPTION:
+# Install the file <conf-file> as service.d/00gentoo.conf template.
+# The <service.d> argument specifies the configured service name.
+# If not specified, the configuration file name will be used with .conf
+# suffix stripped (e.g. foo.service.conf -> foo.service).
+systemd_install_serviced() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local src=${1}
+	local service=${2}
+
+	if [[ ! ${service} ]]; then
+		[[ ${src} == *.conf ]] || die "Source file needs .conf suffix"
+		service=${src##*/}
+		service=${service%.conf}
+	fi
+	# avoid potentially common mistake
+	[[ ${service} != *.d ]] || die "Service must not have .d suffix"
+
+	local INSDESTTREE
+	insinto /etc/systemd/system/"${service}".d
+	newins "${src}" 00gentoo.conf
+}
+
 # @FUNCTION: systemd_dotmpfilesd
 # @USAGE: tmpfilesd1 [...]
 # @DESCRIPTION:
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-09-12 11:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-08 11:12 [gentoo-dev] [PATCH systemd.eclass] Introduce systemd_install_serviced() Michał Górny
2013-09-08 15:14 ` Gilles Dartiguelongue
2013-09-08 15:40   ` Pacho Ramos
2013-09-08 15:46   ` Michał Górny
2013-09-08 21:29     ` Alexis Ballier
2013-09-10 10:57 ` [gentoo-dev] " Steven J. Long
2013-09-10 16:36   ` Michał Górny
2013-09-10 17:28     ` Mike Gilbert
2013-09-12 11:48 ` [gentoo-dev] " Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox