27 lines
728 B
Bash
Executable File
27 lines
728 B
Bash
Executable File
#!/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
|
|
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]+)$'
|
|
)
|
|
echo ${ifx[@]}
|
|
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
|
|
|