#!/bin/bash
# Allow WOL service on active interface
NIC=$(ip -4 a |awk '/state UP/ {print substr($2, 1, length($2)-1)}')
sudo mkdir -p /usr/lib/systemd/system/wol.service.d
echo -e "### /usr/lib/systemd/system/wol.service
[Unit]
Description=Configure Wake-up on LAN

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s $NIC wol g

[Install]
WantedBy=basic.target" | sudo tee /usr/lib/systemd/system/wol.service.d/override.conf > /dev/null
sudo systemctl enable wol.service
sudo systemctl start wol.service
