Files
Server-scripts/network/wol.sh
T

28 lines
793 B
Bash
Raw Normal View History

2026-04-14 23:55:08 +02:00
#!/bin/bash
device=$1
if [ "$device" == "serverhost" ]; then
mac="64:51:06:51:cb:39"
2026-10-12 20:40:28 +02:00
elif [ "$device" == "mediahost" ]; then
mac="9c:6b:00:a3:36:c7"
2026-04-14 23:55:08 +02:00
elif [ "$device" == "quiethost" ]; then
mac="24:4B:FE:DE:93:3E"
elif [ "$(echo ${device} | grep -E -o "([0-9A-Fa-f]{2}[\:]){5}[0-9A-Fa-f]{2}")" != "" ]; then
mac="${device}"
else
printf "Nonsense Input, hostname needed\n"
exit 0
fi
2026-10-03 12:55:05 +02:00
mapfile -t ifx < <(
ip -o link show |
awk -F': ' '{print $2}' |
grep -E '^(eth[0-9]+|en[a-z0-9]+|wlan[0-9]+|wl[a-z0-9]+)$'
)
2026-09-30 17:21:05 +02:00
echo ${ifx[@]}
2026-04-14 23:55:08 +02:00
for i in ${!ifx[@]}; do
sudo /usr/sbin/etherwake -b -i ${ifx[$i]} $mac
printf "%shost succsefully woken via ${ifx[$i]}: ${mac}\n" "$device"
done
if [ "$(echo $SSH_CONNECTION | cut -f1 -d' ')" == "10.0.0.26" ]; then
ssh quiethost notify-send "Woke ${device}"
fi