Skip to content

Commit

Permalink
Improve up_hosts script
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmilton committed Jan 16, 2022
1 parent 143104d commit 6b5346a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion private_dot_config/fish/functions/up_hosts.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function up_hosts --description 'Update dnsmasq blacklist hosts file'
if systemctl is-enabled dnsmasq.service 2>/dev/null
set --local url https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts
set --local temp_file /tmp/hosts
set --local hosts_file /etc/dnsmasq.d/hosts
set --local hosts_file /etc/dnsmasq.d/hosts.conf

# clean up files from last run
rm -f "$temp_file" "$temp_file"-sorted
Expand Down Expand Up @@ -32,6 +32,8 @@ function up_hosts --description 'Update dnsmasq blacklist hosts file'
# remove broken domains (otherwise dnsmasq won't start)
-e '/^0.0.0.0 -/d' \
-e '/--/d' \
# replace hosts file syntax with dnsmasq syntax
-e 's/^0\.0\.0\.0 \(.*\)$/address=\/\1\//g' \
"$temp_file"

# add sorted list
Expand Down

0 comments on commit 6b5346a

Please sign in to comment.