summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/adv_graphgen
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-01-14 16:05:20 +0100
committertv <tv@nomic.retiolum>2013-01-14 16:05:20 +0100
commit3b6a2e967d075145613faffa63ea9399fb6f1800 (patch)
treefe03e97d57cae3cfeed93db652bd4e9deaf6f4b1 /retiolum/scripts/adv_graphgen
parentabd83a5b91c00390300de40b8ada651212efe9a6 (diff)
retiolum find_super: replace xargs with for&wait
Diffstat (limited to 'retiolum/scripts/adv_graphgen')
-rwxr-xr-xretiolum/scripts/adv_graphgen/find_super44
1 files changed, 20 insertions, 24 deletions
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