Skip to content

Commit ddaa6b5

Browse files
Merge pull request #57 from alexanderadam/updates/jan_2025
2 parents b986e99 + 805cf4f commit ddaa6b5

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

scripts/update_hosts.sh

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ HOSTS_FILE="hosts.md"
55
start_time=$(date +%s)
66

77
current_time() {
8-
date +"%H:%M:%S"
8+
date +"%H:%M:%S"
99
}
1010

1111
blocklists=("abuse" "vaping" "torrent" "scam" "ransomware" "porn" "piracy" "phishing" "malware" "fraud" "drugs")
@@ -14,7 +14,7 @@ blocklists_count=${#blocklists[@]}
1414
echo -e " \e[34m[\e[90m$(current_time)\e[34m] Downloading $blocklists_count blocklists\e[0m"
1515

1616
for list in "${blocklists[@]}"; do
17-
wget -q "https://blocklistproject.github.io/Lists/${list}.txt" -O "${list}.txt" &
17+
wget -q "https://blocklistproject.github.io/Lists/${list}.txt" -O "${list}.txt" &
1818
done
1919
wait
2020

@@ -29,18 +29,18 @@ sort -u combined_blocklist.txt -o combined_blocklist.txt
2929
echo -e " \e[32m[\e[90m$(current_time)\e[32m] Blocklists combined\e[0m"
3030

3131
save_domain_entry() {
32-
local domain=$1
33-
local rule_count=$2
34-
local count=$3
35-
local total_domains=$4
36-
local unicode_domain=$(idn --idna-to-unicode "$domain")
37-
local favicon_url="https://icons.duckduckgo.com/ip3/${domain}.ico"
38-
if wget -q --spider "$favicon_url"; then
39-
echo "- <img src=\"${favicon_url}\" width=\"16\" loading=\"lazy\" />&nbsp;${unicode_domain} (${rule_count})" >> "$HOSTS_FILE"
40-
else
41-
echo "- &nbsp;${unicode_domain} (${rule_count})" >> "$HOSTS_FILE"
42-
fi
43-
echo -e " \e[35m[\e[90m$(current_time)\e[35m] $count / $total_domains - \e[34m\e[4m${unicode_domain}\e[0m\e[0m"
32+
local domain=$1
33+
local rule_count=$2
34+
local count=$3
35+
local total_domains=$4
36+
local unicode_domain=$(idn --idna-to-unicode "$domain")
37+
local favicon_url="https://icons.duckduckgo.com/ip3/${domain}.ico"
38+
if wget -q --spider "$favicon_url"; then
39+
echo "- <img src=\"${favicon_url}\" width=\"16\" loading=\"lazy\" />&nbsp;${unicode_domain} (${rule_count})" >> "$HOSTS_FILE"
40+
else
41+
echo "- &nbsp;${unicode_domain} (${rule_count})" >> "$HOSTS_FILE"
42+
fi
43+
echo -e " \e[35m[\e[90m$(current_time)\e[35m] $count / $total_domains - \e[34m\e[4m${unicode_domain}\e[0m\e[0m"
4444
}
4545

4646
# Extract affected hosts and filter against blocklist
@@ -56,12 +56,12 @@ echo -e "# Affected hosts ($total_domains)\n\n" > "$HOSTS_FILE"
5656
count=0
5757

5858
for domain in $domains; do
59-
count=$((count + 1))
60-
if! grep -q "^${domain}$" combined_blocklist.txt; then
61-
rule_count=$(grep -c "^${domain}##" "${FILENAME}")
62-
save_domain_entry "$domain" "$rule_count" "$count" "$total_domains"
63-
affected_hosts+=("$domain")
64-
fi
59+
count=$((count + 1))
60+
if ! grep -q "^${domain}$" combined_blocklist.txt; then
61+
rule_count=$(grep -c "^${domain}##" "${FILENAME}")
62+
save_domain_entry "$domain" "$rule_count" "$count" "$total_domains"
63+
affected_hosts+=("$domain")
64+
fi
6565
done
6666

6767
affected_hosts_count=${#affected_hosts[@]}
@@ -70,7 +70,7 @@ echo -e " \e[32m[\e[90m$(current_time)\e[32m] $affected_hosts_count affected hos
7070
# Clean up
7171
rm -f combined_blocklist.txt
7272
for list in "${blocklists[@]}"; do
73-
rm -f "${list}.txt"
73+
rm -f "${list}.txt"
7474
done
7575

7676
end_time=$(date +%s)

0 commit comments

Comments
 (0)