summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-09-12 11:46:41 +0000
committerMichał Górny <mgorny@gentoo.org>2013-09-12 11:46:41 +0000
commit0f74c2b9862544a3184b5cca505e1a1ca78af559 (patch)
treef6be107cbccab5df7c2cb3bdace56b71fa0580a7 /eclass/systemd.eclass
parentAdd missing test dependencies. (diff)
downloadgentoo-2-0f74c2b9862544a3184b5cca505e1a1ca78af559.tar.gz
gentoo-2-0f74c2b9862544a3184b5cca505e1a1ca78af559.tar.bz2
gentoo-2-0f74c2b9862544a3184b5cca505e1a1ca78af559.zip
Introduce systemd_install_serviced() to install foo.service.d/00gentoo.conf files.
Diffstat (limited to 'eclass/systemd.eclass')
-rw-r--r--eclass/systemd.eclass31
1 files changed, 30 insertions, 1 deletions
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index d988102c0bbf..c4623fba0fd2 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.29 2013/09/11 08:53:18 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.30 2013/09/12 11:46:41 mgorny Exp $
# @ECLASS: systemd.eclass
# @MAINTAINER:
@@ -133,6 +133,35 @@ systemd_newunit() {
)
}
+# @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}
+
+ [[ ${src} ]] || die "No file specified"
+
+ 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"
+
+ (
+ insinto /etc/systemd/system/"${service}".d
+ newins "${src}" 00gentoo.conf
+ )
+}
+
# @FUNCTION: systemd_dotmpfilesd
# @USAGE: <tmpfilesd>...
# @DESCRIPTION: