#!/bin/sh

echo "done" > "/tmp/done.txt"

set -e
sleep 15s

function enable_wol_for() {
	echo "[enable_wol] enabling wol on '$1'"
	sudo ethtool -s $1 wol g
	echo "[enable_wol] success"
	sudo ethtool $1 | grep Wake-on
}

for _ in $(seq 10)
do
	ip link | grep enp | while read line; do
		name=$(echo "$line" | cut -d ":" -f 2)
		enable_wol_for "$name"
	done
	sleep 10s
done
