1 |
This function can be used to install service configuration templates. |
2 |
Usage: |
3 |
|
4 |
systemd_install_serviced "${FILESDIR}"/foo.service.conf |
5 |
|
6 |
or: |
7 |
|
8 |
systemd_install_serviced "${FILESDIR}"/barbaz foo.service |
9 |
|
10 |
with the latter specifying related service name explicitly, former |
11 |
expecting it to match ${basename%.conf}. The files are installed as: |
12 |
|
13 |
/etc/systemd/system/foo.service.d/00gentoo.conf |
14 |
|
15 |
They should be commented out templates that users can use to customize |
16 |
the service easily. |
17 |
--- |
18 |
gx86/eclass/systemd.eclass | 26 ++++++++++++++++++++++++++ |
19 |
1 file changed, 26 insertions(+) |
20 |
|
21 |
diff --git a/gx86/eclass/systemd.eclass b/gx86/eclass/systemd.eclass |
22 |
index 4566631..1575b78 100644 |
23 |
--- a/gx86/eclass/systemd.eclass |
24 |
+++ b/gx86/eclass/systemd.eclass |
25 |
@@ -131,6 +131,32 @@ systemd_newunit() { |
26 |
newins "${@}" |
27 |
} |
28 |
|
29 |
+# @FUNCTION: systemd_install_serviced |
30 |
+# @USAGE: <conf-file> [<service.d>] |
31 |
+# @DESCRIPTION: |
32 |
+# Install the file <conf-file> as service.d/00gentoo.conf template. |
33 |
+# The <service.d> argument specifies the configured service name. |
34 |
+# If not specified, the configuration file name will be used with .conf |
35 |
+# suffix stripped (e.g. foo.service.conf -> foo.service). |
36 |
+systemd_install_serviced() { |
37 |
+ debug-print-function ${FUNCNAME} "${@}" |
38 |
+ |
39 |
+ local src=${1} |
40 |
+ local service=${2} |
41 |
+ |
42 |
+ if [[ ! ${service} ]]; then |
43 |
+ [[ ${src} == *.conf ]] || die "Source file needs .conf suffix" |
44 |
+ service=${src##*/} |
45 |
+ service=${service%.conf} |
46 |
+ fi |
47 |
+ # avoid potentially common mistake |
48 |
+ [[ ${service} != *.d ]] || die "Service must not have .d suffix" |
49 |
+ |
50 |
+ local INSDESTTREE |
51 |
+ insinto /etc/systemd/system/"${service}".d |
52 |
+ newins "${src}" 00gentoo.conf |
53 |
+} |
54 |
+ |
55 |
# @FUNCTION: systemd_dotmpfilesd |
56 |
# @USAGE: tmpfilesd1 [...] |
57 |
# @DESCRIPTION: |
58 |
-- |
59 |
1.8.3.2 |