Wake up all clients returned by '--list-hosts'.

This commit is contained in:
Andreas B. Mundt 2023-10-21 18:19:12 +02:00
parent a586ac5201
commit dba478652a

17
wol-generator.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/bash
#
# Pipe the '--list-hosts' output of ansible into this program to wake up all corresponding hosts:
#
# ansible-playbook [...] -i inventory/inventory.yml -l R317 --list-hosts | ./wol-generator.sh
#
set -eu
tmpf="$(mktemp)"
devs='devices.csv'
while read -r line ; do
sed -nE -e "s%.*(..:..:..:..:..:..);(${line//./\\.});.*%\1 \2%p" "$devs" >> "$tmpf"
done < <(cat - | grep -E "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")
wakeonlan -f "$tmpf"
rm "$tmpf"