wip
This commit is contained in:
parent
f49928bed1
commit
aad74c13d4
3 changed files with 37 additions and 18 deletions
|
@ -22,9 +22,6 @@ def systemd(metadata):
|
|||
'Persistent': config.get('persistent', False),
|
||||
'Unit': f'{name}.service',
|
||||
},
|
||||
'Install': {
|
||||
'WantedBy': 'multi-user.target',
|
||||
},
|
||||
},
|
||||
f'{name}.service': {
|
||||
'Unit':{
|
||||
|
|
|
@ -7,15 +7,6 @@
|
|||
'systemd': {
|
||||
'units': {
|
||||
'test.service': {
|
||||
# optional: will be derived from unit extension
|
||||
'path': '/etc/systemd/system/test.service',
|
||||
# content of the unit file
|
||||
'content': {
|
||||
},
|
||||
# bw item data
|
||||
# applies to unitfile and svc_systemd aswell, if present
|
||||
'item': {
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -8,19 +8,50 @@ defaults = {
|
|||
@metadata_reactor.provides(
|
||||
'systemd/units',
|
||||
)
|
||||
def services(metadata):
|
||||
def units(metadata):
|
||||
units = {}
|
||||
|
||||
for name, config in metadata.get('systemd/units').items():
|
||||
if name.split('.')[-1] == 'service' and not config.get('Install/WantedBy'):
|
||||
units[name] = {
|
||||
'Install': {
|
||||
'WantedBy': ['multi-user.target'],
|
||||
extension = name.split('.')[-1]
|
||||
|
||||
if extension not in ['timer', 'service', 'network', 'netdev']:
|
||||
raise Exception(f'unknown extension {extension}')
|
||||
|
||||
if not config.get('Install/WantedBy'):
|
||||
if extension == 'service':
|
||||
units[name] = {
|
||||
'Install': {
|
||||
'WantedBy': ['multi-user.target'],
|
||||
}
|
||||
}
|
||||
elif extension == 'timer':
|
||||
units[name] = {
|
||||
'Install': {
|
||||
'WantedBy': ['timers.target'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
'systemd': {
|
||||
'units': units,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'systemd/services',
|
||||
)
|
||||
def services(metadata):
|
||||
services = {}
|
||||
|
||||
for name, config in metadata.get('systemd/services').items():
|
||||
extension = name.split('.')[-1]
|
||||
|
||||
if extension not in ['timer', 'service']:
|
||||
raise Exception(f'unknown extension {extension}')
|
||||
|
||||
return {
|
||||
'systemd': {
|
||||
'services': services,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue