From b9e33a9bc89787cd9e4cf053e9f03490f249e815 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 26 Jul 2023 15:55:30 +0200 Subject: [PATCH] Failsafe from unreachable URLs, sed edits inline, slow download of URLs, added marker vor debugging --- .gitignore | 2 +- README.md | 4 ++-- create-adblock.sh | 30 +++++++++++++++++++----------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 88c5893..da7f22d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ all-adblock.txt -header.txt own-rules.txt +pre-adblock.txt .htaccess .htpasswd diff --git a/README.md b/README.md index 97a986d..364240d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Anleitung -* `header.txt.template` umbenennen in `header.txt` +* `own-rules.txt.template` umbenennen in `own-rules.txt` * eigene Regeln einfügen (zum Beispiel aus den eigens eingesetzten Adblockern extrahieren) * die URLs zu Adblocklisten in `adblocklists.txt` anpassen * lokales Verzeichnis zu diesen Dateien in `create-adblock.sh:2` angeben * Cronjob auf `create-adblock.sh` anlegen (z.B. alle zwei Tage - nicht zu oft, ob die Quelllisten nicht zu überfordern) * Skript einmalig ausführen `chmod 0744 create-adblock.sh && bash create-adblock.sh` -* Im Adblocker http(s)://URL/all-adblock.txt angeben +* Im Adblocker `http(s)://URL/all-adblock.txt` angeben diff --git a/create-adblock.sh b/create-adblock.sh index 0acffbb..4639d14 100755 --- a/create-adblock.sh +++ b/create-adblock.sh @@ -1,27 +1,35 @@ #!/bin/bash -set -e -u -#Adblock Listen herunterladen +echo "" > pre-adblock.txt + +#Adblock lists download while read p; do - wget -qO - $p >> all-adblock.txt + echo "#!MARKER- Begin of $p" >> pre-adblock.txt + wget -qO - $p >> pre-adblock.txt + sleep 2 done allfilters.txt +#Remove comments in lists +sed -i 's/^!.*$//g' pre-adblock.txt -#Header erstellen -echo '! Title: Mainboarder kompiliert +#Change marker to comment +sed -i 's/#!MARKER-/!/g' pre-adblock.txt + +#Create Header +echo '! Title: Mainboarder compiled ! Description: Filters optimized for uBlock, for single list use, deduplicated ! Expires: 2 days ! Last modified: '"$date"' ! Homepage: https://git.mainboarder.de/Public/Adblocker !' > all-adblock.txt -#Eigene Regeln hinzufügen +#Add own rules cat own-rules.txt >> all-adblock.txt -#Duplikate entfernen -awk '!seen[$0]++' allfilters.txt >> all-adblock.txt -rm allfilters.txt +#Remove duplicate lines +awk '!seen[$0]++' pre-adblock.txt >> all-adblock.txt