test if removed hosts are still online
This commit is contained in:
parent
c46eb8b3d0
commit
c45f58fd20
29
get-hosts.sh
29
get-hosts.sh
|
@ -68,6 +68,35 @@ if [ -z "$hosts" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Save to temporary file.
|
||||||
|
tempfile=$(mktemp)
|
||||||
|
echo "$hosts" > "$tempfile"
|
||||||
|
|
||||||
|
# Delete temporary file on exit.
|
||||||
|
finish() {
|
||||||
|
rm -f "$tempfile"
|
||||||
|
}
|
||||||
|
trap finish EXIT
|
||||||
|
|
||||||
|
# Test if removed hosts are still online.
|
||||||
|
echo "Testing removed hosts..."
|
||||||
|
for removed_host in $(diff hosts "$tempfile" | grep ^\< | cut -c 3-); do
|
||||||
|
printf "%s" "$removed_host"
|
||||||
|
# If direct connection fails, try to connect through Tor.
|
||||||
|
if agunua --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1 || \
|
||||||
|
agunua --socks 127.0.0.1:9050 --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1; then
|
||||||
|
echo " - ONLINE"
|
||||||
|
# Add removed host back.
|
||||||
|
hosts="$hosts
|
||||||
|
$removed_host"
|
||||||
|
else
|
||||||
|
echo " - offilne"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Sort entries again.
|
||||||
|
hosts=$(echo "$hosts" | sort)
|
||||||
|
|
||||||
# Save to file.
|
# Save to file.
|
||||||
echo "$hosts" > hosts
|
echo "$hosts" > hosts
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue