check if hosts file exists before testing removed hosts
This commit is contained in:
parent
eb6c24c12b
commit
8342535886
28
get-hosts.sh
28
get-hosts.sh
|
@ -79,20 +79,22 @@ finish() {
|
||||||
trap finish EXIT
|
trap finish EXIT
|
||||||
|
|
||||||
# Test if removed hosts are still online.
|
# Test if removed hosts are still online.
|
||||||
echo "Testing removed hosts..."
|
if [ -f hosts ]; then
|
||||||
for removed_host in $(diff hosts "$tempfile" | grep ^\< | cut -c 3-); do
|
echo "Testing removed hosts..."
|
||||||
printf "%s" "$removed_host"
|
for removed_host in $(diff hosts "$tempfile" | grep ^\< | cut -c 3-); do
|
||||||
# If direct connection fails, try to connect through Tor.
|
printf "%s" "$removed_host"
|
||||||
if agunua --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1 || \
|
# If direct connection fails, try to connect through Tor.
|
||||||
agunua --socks 127.0.0.1:9050 --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1; then
|
if agunua --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1 || \
|
||||||
echo " - ONLINE"
|
agunua --socks 127.0.0.1:9050 --no-tofu --maximum-time 20 "$removed_host" >/dev/null 2>&1; then
|
||||||
# Add removed host back.
|
echo " - ONLINE"
|
||||||
hosts="$hosts
|
# Add removed host back.
|
||||||
|
hosts="$hosts
|
||||||
$removed_host"
|
$removed_host"
|
||||||
else
|
else
|
||||||
echo " - offline"
|
echo " - offline"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Sort entries again.
|
# Sort entries again.
|
||||||
hosts=$(echo "$hosts" | sort)
|
hosts=$(echo "$hosts" | sort)
|
||||||
|
|
Loading…
Reference in New Issue