From 3b6a2e967d075145613faffa63ea9399fb6f1800 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 14 Jan 2013 16:05:20 +0100 Subject: retiolum find_super: replace xargs with for&wait --- retiolum/scripts/adv_graphgen/find_super | 44 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'retiolum') diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super index e971e204..17a0c8c0 100755 --- a/retiolum/scripts/adv_graphgen/find_super +++ b/retiolum/scripts/adv_graphgen/find_super @@ -1,25 +1,21 @@ #! /bin/dash -set -euf -case "${1-all}" in - (all) - find /etc/tinc/retiolum/hosts -type f | - xargs -P 423 -n 1 "$0" one - ;; - (one) - hosts_file=$2 - name=$(basename $hosts_file) - - if grep -q Address $hosts_file; then - script="$(sed -n ' - s/[[:space:]]*//g - s/^\(Address\|Port\)=\(.*\)/\1="${\1+$\1 }\2"/p - ' $hosts_file)" - eval "$script" - for address in ${Address-}; do - if nc -zw 2 $address 655 2>/dev/null; then - echo $name - $address reachable - fi & - done - wait - fi -esac +set -eu +cd /etc/tinc/retiolum/hosts +for name in ` + grep '^[[:space:]]*Address[[:space:]]*=' * | + cut -d: -f1 | sort | uniq +`; do + if eval "`sed -n ' + s/[[:space:]]\+//g + s/^\(Address\|Port\)=\(.*\)/\1="\${\1+\$\1\n}\2"/p + ' $name`"; then + port=${Port-655} + for host in $Address; do + if nc -zw 2 $host $port 2>/dev/null; then + echo $name - $host reachable + fi & + done + wait + fi & +done +wait -- cgit v1.2.3