bundlewrap/bundles/systemd/items.py
mwiegand 42d1dd433c wip
2021-07-13 16:50:08 +02:00

39 lines
1 KiB
Python

from bundlewrap.utils.dicts import merge_dict
actions = {
'systemd-reload': {
'command': 'systemctl daemon-reload',
'cascade_skip': False,
'triggered': True,
},
}
for name, unit in node.metadata.get('systemd/units').items():
extension = name.split('.')[-1]
if extension in ['netdev', 'network']:
path = f'/etc/systemd/network/{name}'
dependencies = {
'triggers': [
'svc_systemd:systemd-networkd:restart',
],
}
elif extension in ['timer', 'service']:
path = f'/etc/systemd/system/{name}'
dependencies = {
'triggers': [
"action:systemd-reload",
],
}
files[path] = {
'content': repo.libs.systemd.generate_unitfile(unit),
**dependencies,
}
for name, config in node.metadata.get('systemd/services').items():
svc_systemd[name] = merge_dict(config, {
'needs': [
'action:systemd-reload',
],
})