check if hosts file exists before testing removed hosts

This commit is contained in:
nervuri 2022-08-07 00:00:00 +00:00
parent eb6c24c12b
commit 8342535886
1 changed files with 15 additions and 13 deletions

View File

@ -79,8 +79,9 @@ finish() {
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
if [ -f hosts ]; then
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 || \
@ -92,7 +93,8 @@ $removed_host"
else
echo " - offline"
fi
done
done
fi
# Sort entries again.
hosts=$(echo "$hosts" | sort)