bundlewrap/bundles/systemd-timers/metadata.py
mwiegand aad74c13d4 wip
2021-07-13 16:49:57 +02:00

42 lines
1 KiB
Python

defaults = {
'systemd-timers': {},
}
@metadata_reactor.provides(
'systemd/units',
'systemd/services',
)
def systemd(metadata):
units = {}
services = {}
for name, config in metadata.get('systemd-timers').items():
units.update({
f'{name}.timer': {
'Unit':{
'Description': f'{name} timer',
},
'Timer': {
'OnCalendar': config['when'],
'Persistent': config.get('persistent', False),
'Unit': f'{name}.service',
},
},
f'{name}.service': {
'Unit':{
'Description': f'{name} timer service',
},
'Service': {
'ExecStart': config['command'],
},
},
})
services[f'{name}.timer'] = {}
return {
'systemd': {
'units': units,
'services': services,
},
}