Skip to content

Instantly share code, notes, and snippets.

@hunterkepley
Created April 27, 2025 15:08
Show Gist options
  • Save hunterkepley/c0c54308b3d111d4ca3528a2b612e244 to your computer and use it in GitHub Desktop.
Save hunterkepley/c0c54308b3d111d4ca3528a2b612e244 to your computer and use it in GitHub Desktop.
update-blocklist-pihole
#!/bin/bash
# vars
src=/home/pi/src
#in=$src/in
out=$src/out
rawout=$out/combined.raw
procout=$out/combined.processed
srclist=$src/src.list
pihole=/etc/pihole
# pull raw in files from sources
# clean out old file first
[[ -f $rawout ]] && rm $rawout
for s in $(cat $srclist | grep -v "^#")
do
curl $s >>$rawout
done
# now prepare the rawout formating for pihole
[[ -f $procout ]] && rm $procout
cat $rawout | egrep -v "^!" |sed 's/^||//' |cut -d'^' -f-1 >>$procout
# now add to pihole's blacklist
cat $pihole/blacklist.txt >> $procout
# sort unique
sort -u $procout > $out/blacklist.txt2
sudo rm $pihole/blacklist.txt
sudo mv $out/blacklist.txt2 $pihole/blacklist.txt
pihole -g
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment