summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-01-14 15:14:46 +0100
committertv <tv@nomic.retiolum>2013-01-14 15:14:46 +0100
commitabd83a5b91c00390300de40b8ada651212efe9a6 (patch)
tree820ef1717711d49ec63500920b391ee2b2e30dec
parentabf9916bc1add17888308877fa4eb9da330297ef (diff)
retiolum find_super: parallel lookup
-rwxr-xr-x[-rw-r--r--]retiolum/scripts/adv_graphgen/find_super37
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