bundlewrap/bundles/wol-sleeper/metadata.py
2022-02-12 17:15:15 +01:00

45 lines
1.2 KiB
Python

@metadata_reactor.provides(
'apt/packages/ethtool',
'systemd/units/enable-wol',
'systemd/services/enable-wol.service',
)
def systemd(metadata):
interfaces = set(
conf['interface']
for conf in metadata.get('network').values()
if conf.get('wol', False)
)
if not interfaces:
return {}
return {
'apt': {
'packages': {
'ethtool': {},
},
},
'systemd': {
'units': {
'enable-wol.service': {
'Unit': {
'After': 'network.target',
},
'Service': {
'Type': 'oneshot',
'RemainAfterExit': 'yes',
'ExecStart': set(
f"ethtool -s {interface} wol g"
for interface in interfaces
),
},
'Install': {
'WantedBy': 'multi-user.target',
},
},
},
'services': {
'enable-wol.service': {},
},
},
}