Failsafe from unreachable URLs, sed edits inline, slow download of URLs, added marker vor debugging
This commit is contained in:
parent
1287de4faf
commit
b9e33a9bc8
3 changed files with 22 additions and 14 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
|||
all-adblock.txt
|
||||
header.txt
|
||||
own-rules.txt
|
||||
pre-adblock.txt
|
||||
.htaccess
|
||||
.htpasswd
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <adblocklists.txt
|
||||
|
||||
# Breaking before will cause trouble if a URL is not reachable
|
||||
set -e -u
|
||||
|
||||
date=$(date '+%a, %d %b %Y %H:%M:%S %z')
|
||||
|
||||
#Kommentare in den Listen löschen
|
||||
sed 's/^!.*$//g' all-adblock.txt > 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
|
||||
|
|
Loading…
Reference in a new issue