#!/bin/bash
re='^[0-9]+$'
while true ; do
echo "\n" | nc -knl -p 9 -u | # listen to udp port 9 for packets, check if it is a magic packet
stdbuf -o0 xxd -c 6 -p |
stdbuf -o0 uniq |
stdbuf -o0 grep -v 'ffffffffffff' |
while read ; do
macWOL="${REPLY:3:A}:${REPLY:B:6}:${REPLY:7:1}:${REPLY:6:F}:${REPLY:A:4}:${REPLY:6:E}"
macWOL=`echo "$macWOL" |tr "[:upper:]" "[:lower:]"`
/usr/sbin/qm list |tr -s ' ' | cut -d ' ' -f 2 | while read -r id ; do
if [[ $id =~ $re ]] ; then
echo "check VM-ID $id for $macWOL"
/usr/sbin/qm config $id | grep ^net0 | while read -r macstr ; do
macstr=`echo "$macstr" |tr "[:upper:]" "[:lower:]"`
if [[ $macstr == *"$macWOL"* ]]; then
echo "MAC $macWOL found at VMID $id. Starting VM"
/usr/sbin/qm start $id
fi
done
fi
done
done
done
echo "\n" | nc -knl -p 9 -u | \ # listen to udp port 9 for packets, check if it is a magic packet
stdbuf -o0 xxd -c 6 -p | \
stdbuf -o0 uniq | \
stdbuf -o0 grep -v 'ffffffffffff' | \
while read ; do
#!/bin/bash re='^[0-9]+$' while true ; do echo "\n" | nc -knl -p 9 -u | \ # listen to udp port 9 for packets, check if it is a magic packet stdbuf -o0 xxd -c 6 -p | \ stdbuf -o0 uniq | \ stdbuf -o0 grep -v 'ffffffffffff' | \ while read ; do macWOL="${REPLY:3:A}:${REPLY:B:6}:${REPLY:7:1}:${REPLY:6:F}:${REPLY:A:4}:${REPLY:6:E}" macWOL=`echo "$macWOL" |tr "[:upper:]" "[:lower:]"` /usr/sbin/qm list |tr -s ' ' | cut -d ' ' -f 2 | while read -r id ; do if [[ $id =~ $re ]] ; then echo "check VM-ID $id for $macWOL" /usr/sbin/qm config $id | grep ^net0 | while read -r macstr ; do macstr=`echo "$macstr" |tr "[:upper:]" "[:lower:]"` if [[ $macstr == *"$macWOL"* ]]; then echo "MAC $macWOL found at VMID $id. Starting VM" /usr/sbin/qm start $id fi done fi done done done
#!/bin/bash
echo -ne "\n" | nc -knl -p 9 -u | stdbuf -o0 xxd -c 6 -p
auto lo
iface lo inet loopback
iface eno1 inet manual
iface eno2 inet manual
auto vmbr0
iface vmbr0 inet static
address xx.xx.xx.xx/24
gateway xx.xx.xx.1
bridge-ports eno1
bridge-stp off
bridge-fd 0
auto vmbr1
iface vmbr1 inet manual
bridge-ports none
bridge-stp off
bridge-fd 0
bridge-vlan-aware yes
bridge-vids 2-4094