summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd')
-rwxr-xr-xmeta/recipes-core/systemd/systemd-systemctl/systemctl14
1 files changed, 11 insertions, 3 deletions
diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index 990de1ab39..6aa2e20465 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -11,6 +11,7 @@ import re
11import sys 11import sys
12 12
13from collections import namedtuple 13from collections import namedtuple
14from itertools import chain
14from pathlib import Path 15from pathlib import Path
15 16
16version = 1.0 17version = 1.0
@@ -25,12 +26,16 @@ locations = list()
25 26
26class SystemdFile(): 27class SystemdFile():
27 """Class representing a single systemd configuration file""" 28 """Class representing a single systemd configuration file"""
28 def __init__(self, root, path): 29 def __init__(self, root, path, instance_unit_name):
29 self.sections = dict() 30 self.sections = dict()
30 self._parse(root, path) 31 self._parse(root, path)
31 dirname = os.path.basename(path.name) + ".d" 32 dirname = os.path.basename(path.name) + ".d"
32 for location in locations: 33 for location in locations:
33 for path2 in sorted((root / location / "system" / dirname).glob("*.conf")): 34 files = (root / location / "system" / dirname).glob("*.conf")
35 if instance_unit_name:
36 inst_dirname = instance_unit_name + ".d"
37 files = chain(files, (root / location / "system" / inst_dirname).glob("*.conf"))
38 for path2 in sorted(files):
34 self._parse(root, path2) 39 self._parse(root, path2)
35 40
36 def _parse(self, root, path): 41 def _parse(self, root, path):
@@ -193,8 +198,11 @@ class SystemdUnit():
193 # if we're enabling an instance, first extract the actual instance 198 # if we're enabling an instance, first extract the actual instance
194 # then figure out what the template unit is 199 # then figure out what the template unit is
195 template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit) 200 template = re.match(r"[^@]+@(?P<instance>[^\.]*)\.", self.unit)
201 instance_unit_name = None
196 if template: 202 if template:
197 instance = template.group('instance') 203 instance = template.group('instance')
204 if instance != "":
205 instance_unit_name = self.unit
198 unit = re.sub(r"@[^\.]*\.", "@.", self.unit, 1) 206 unit = re.sub(r"@[^\.]*\.", "@.", self.unit, 1)
199 else: 207 else:
200 instance = None 208 instance = None
@@ -206,7 +214,7 @@ class SystemdUnit():
206 # ignore aliases 214 # ignore aliases
207 return 215 return
208 216
209 config = SystemdFile(self.root, path) 217 config = SystemdFile(self.root, path, instance_unit_name)
210 if instance == "": 218 if instance == "":
211 try: 219 try:
212 default_instance = config.get('Install', 'DefaultInstance')[0] 220 default_instance = config.get('Install', 'DefaultInstance')[0]