diff options
author | tv <tv@nomic.retiolum> | 2013-01-14 15:14:46 +0100 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2013-01-14 15:14:46 +0100 |
commit | abd83a5b91c00390300de40b8ada651212efe9a6 (patch) | |
tree | 820ef1717711d49ec63500920b391ee2b2e30dec /retiolum | |
parent | abf9916bc1add17888308877fa4eb9da330297ef (diff) |
retiolum find_super: parallel lookup
Diffstat (limited to 'retiolum')
-rwxr-xr-x[-rw-r--r--] | retiolum/scripts/adv_graphgen/find_super | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/retiolum/scripts/adv_graphgen/find_super b/retiolum/scripts/adv_graphgen/find_super index c89a94fb..e971e204 100644..100755 --- a/retiolum/scripts/adv_graphgen/find_super +++ b/retiolum/scripts/adv_graphgen/find_super @@ -1,14 +1,25 @@ -#!/bin/sh -cd /etc/tinc/retiolum/hosts -ls -1 . | while read fname; -do - for i in `sed -n 's/Address\s*=\s*\(.*\)/\1/p' $fname`;do - if nc -zw 5 $i 655 2>/dev/null; then - echo "$fname - $i reachable" - #else - #echo -n - #echo "$fname - $i unreachable" +#! /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) - fi - done -done + 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 |