From 92c5323ed78e9e89217dd70c1187dbeb83d0ec76 Mon Sep 17 00:00:00 2001 From: columndeeply Date: Fri, 2 Sep 2022 20:20:17 +0200 Subject: [PATCH] Add whitelist script --- scripts/whitelist.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scripts/whitelist.sh diff --git a/scripts/whitelist.sh b/scripts/whitelist.sh new file mode 100755 index 0000000..5a9ab3c --- /dev/null +++ b/scripts/whitelist.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env sh +# Removes any domains it find on the whitelist +# + +# Remove temp file from previous runs if needed +rm -f merged.tmp + +# Merge all files into one +cat ../hosts* > merged.tmp + +# Remove the old lists +rm -f ../hosts* + +# Remove duplicates +sort < merged.tmp | uniq > merged + +# Check whitelist and remove matches +comm -2 -3 merged ../whitelist > merged2 +mv merged2 merged + +# Split the merged file into 90MB chunks to avoid GitHub's limit +split merged hosts -C 90MB -d + +# Move the new hosts files and the merged list to the parent directory +mv hosts* .. +mv merged .. + +# Show how many changes in total +git diff --stat ../hosts* + +# Remove tmp files +rm -- merged.tmp