From dba478652ac285e20ed5ac75c6c97b6ce5234111 Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" Date: Sat, 21 Oct 2023 18:19:12 +0200 Subject: [PATCH] Wake up all clients returned by '--list-hosts'. --- wol-generator.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 wol-generator.sh diff --git a/wol-generator.sh b/wol-generator.sh new file mode 100755 index 0000000..02ebd44 --- /dev/null +++ b/wol-generator.sh @@ -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"