Raspberry Pi As Wake on LAN Server.
1) Install "etherwake" package:
Code: Select all
$ apt install etherwake
Here's the quick-n-dirty BASH hack:
Code: Select all
#!/bin/bash
TARGET="$1"
DHCP_CONF="/etc/dhcp/dhcpd.conf"
# Grep the MAC address from the DHCP config file:
CMD="grep -A 2 -i 'host $TARGET' $DHCP_CONF | grep 'hardware ethernet' | cut -d ' ' -f 5"
MAC_ID=$(eval "$CMD")
# MAC IDs are 17 digits long. Cut it:
MAC_ID=${MAC_ID:0:17}
echo "$TARGET=$MAC_ID"
etherwake $MAC_ID
"./wol.sh HOSTNAME"
It will then search the hostname in dhcpd.conf, grep its ethernet line and cut that to the address string.
When it has that, it calls `etherwake`. The target HOSTNAME should now wake up
Thanks Quintaar!