Files
Server-scripts/wol.sh
T

21 lines
652 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"
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
ifx=( $(/sbin/ip -br l | awk '$1 !~ "lo|vir|wl" { print $1}') )
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