Fork of https://gitlab.com/grublets/youtube-updater-for-pi-hole
This for has
- Looking sqlite db for youtube domains instead of log file
- Support for googlevideo.com and gvt1.com
Installation instructions are
Fork of https://gitlab.com/grublets/youtube-updater-for-pi-hole
This for has
Installation instructions are
| #!/bin/bash | |
| # crappy hack that seems to keep YouTube ads to a minumum. | |
| # over two hours of Peppa Pig and no ads. Taking one for the team... | |
| # [email protected] v0.11 | |
| # Change forceIP to the real IP from an nslookup of a | |
| # googlevideo hostname so you get something in your | |
| # geographical region. You can find one in your | |
| # Pi-hole's query logs. | |
| # They will look something like this: | |
| # r3---sn-ci5gup-h55e.googlevideo.com | |
| # r7---sn-ci5gup-h55l.gvt1.com | |
| # as root: run this once then run "pihole restartdns" | |
| # You can cron this for auto-updating of the host file. | |
| # Mine fires every 5 minute: | |
| #*/5 * * * * sudo /usr/local/bin/youtube.update.sh 2>&1 | |
| forceIP="123.456.789.999" | |
| # nothing below here should need changing | |
| piDB="/etc/pihole/pihole-FTL.db" | |
| ytHosts="/etc/hosts.youtube" | |
| workFile=$(mktemp) | |
| dnsmasqFile="/etc/dnsmasq.d/99-youtube.grublets.conf" | |
| if [ ! -f $dnsmasqFile ]; then | |
| echo "addn-hosts=$ytHosts" > $dnsmasqFile | |
| touch $ytHosts | |
| echo "Setup complete! Execute 'pihole restartdns' as root." | |
| echo "cron the script to run every 5 minute or so for updates." | |
| fi | |
| cp $ytHosts $workFile | |
| sqlite3 $piDB "SELECT distinct domain FROM queries WHERE domain LIKE '%-%.googlevideo.com' OR domain LIKE '%-%.gvt1.com'" \ | |
| | awk -v fIP=$forceIP '{ print fIP, $1 }' >> $workFile | |
| sort -u $workFile -o $workFile | |
| if ! cmp $workFile $ytHosts; then | |
| mv $workFile $ytHosts | |
| chmod 644 $ytHosts | |
| /usr/local/bin/pihole restartdns reload | |
| else | |
| rm $workFile | |
| fi | |
| exit |