summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2021-03-26 10:38:56 +0100
committerMarc Vertes <mvertes@free.fr>2021-03-26 10:38:56 +0100
commit73aec290b0f95b7be7ef952b042359bb95b18645 (patch)
tree6dbb2419139868f018b747f3c9b09dcf7cb95084
parent262eb286cb7c8d7412160cacfb022247b1f09f00 (diff)
improve update_hosts
-rwxr-xr-xbin/update_hosts4
1 files changed, 3 insertions, 1 deletions
diff --git a/bin/update_hosts b/bin/update_hosts
index 6444550..793344c 100755
--- a/bin/update_hosts
+++ b/bin/update_hosts
@@ -1,9 +1,10 @@
-#!/bin/sh -ex
+#!/bin/sh -e
# Update /etc/hosts with a well curated blacklist of malware, ads, porn, etc.
# Custom hosts are preserved.
[ "$USER" = root ] || exec sudo "$0" "$@"
+echo "last update: $(date -r /etc/hosts)"
cd /etc
cp -p hosts hosts.old
hosts=$(awk '/^# Custom host /, /^# End of custom host /' hosts.old)
@@ -14,3 +15,4 @@ awk 'BEGIN { hosts = ARGV[1]; ARGV[1] = "" }
{print}' "$hosts" > hosts.new
mv hosts.new hosts
[ "$(uname -s)" != Darwin ] || dscacheutil -flushcache
+diff -u /etc/hosts.old /etc/hosts | diffstat