wol-sleeper
This commit is contained in:
parent
b579dc4928
commit
98ba428bb7
4 changed files with 75 additions and 0 deletions
28
bundles/wol-sleeper/README.md
Normal file
28
bundles/wol-sleeper/README.md
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# wake on lan
|
||||||
|
|
||||||
|
## woken
|
||||||
|
|
||||||
|
wol by magic packet
|
||||||
|
|
||||||
|
```
|
||||||
|
ethtool -s enp1s0 wol g
|
||||||
|
```
|
||||||
|
|
||||||
|
p Wake on phy activity
|
||||||
|
u Wake on unicast messages
|
||||||
|
m Wake on multicast messages
|
||||||
|
b Wake on broadcast messages
|
||||||
|
a Wake on ARP
|
||||||
|
g Wake on MagicPacket(tm)
|
||||||
|
s Enable SecureOn(tm) password for MagicPacket(tm)
|
||||||
|
d Disable (wake on nothing). This option clears all previous options.
|
||||||
|
|
||||||
|
```
|
||||||
|
systemctl suspend
|
||||||
|
```
|
||||||
|
|
||||||
|
## waker
|
||||||
|
|
||||||
|
```
|
||||||
|
wakeonlan d8:cb:8a:e7:be:c6
|
||||||
|
```
|
45
bundles/wol-sleeper/metadata.py
Normal file
45
bundles/wol-sleeper/metadata.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
@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 {conf['interface']} wol g"
|
||||||
|
for itnerface in interfaces
|
||||||
|
),
|
||||||
|
},
|
||||||
|
'Install': {
|
||||||
|
'WantedBy': 'multi-user.target',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'services': {
|
||||||
|
'enable-wol.service': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
'bundles': {
|
'bundles': {
|
||||||
'hardware',
|
'hardware',
|
||||||
|
'wol-sleeper',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
'interface': 'enp1s0',
|
'interface': 'enp1s0',
|
||||||
'ipv4': '10.0.0.5/24',
|
'ipv4': '10.0.0.5/24',
|
||||||
'gateway4': '10.0.0.1',
|
'gateway4': '10.0.0.1',
|
||||||
|
'wol': True,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'backup-server': {
|
'backup-server': {
|
||||||
|
|
Loading…
Reference in a new issue