forked from kboghdady/youTube_ads_4_pi-hole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutube.sh
executable file
·36 lines (26 loc) · 1.44 KB
/
youtube.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# Update the pihole list with youtube ads
# this shell script is made by Kiro
#Thank you for using it and enjoy
# The script will create a file with all the youtube ads found in hostsearch and from the logs of the Pi-hole
# it will append the list into a file called blacklist.txt'/etc/pihole/blacklist.txt'
piholeIPV4=$(hostname -I |awk '{print $1}')
piholeIPV6=$(hostname -I |awk '{print $2}')
blackListFile='/etc/pihole/black.list'
blacklist='/etc/pihole/blacklist.txt'
# Get the list from the GitHub and add it to the blacklist.txt
sudo curl 'https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/black.list'\
>>$blacklist
sudo curl 'https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/black.list'\
>>$blackListFile
# Get the list from the GitHub and add it to the blacklist.txt with Pihole IPV4 and IPV6 to black.list
sudo curl 'https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/black.list' |awk -v a=$piholeIPV4 '{print a " " $1}'|sort |uniq>>$blackListFile
sudo curl 'https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/black.list' |awk -v a=$piholeIPV6 '{print a " " $1}'|sort |uniq>>$blackListFile
wait
# check to see if gawk is installed. if not it will install it
dpkg -l | grep -qw gawk || sudo apt-get install gawk -y
wait
# remove the duplicate records in place
gawk -i inplace '!a[$0]++' $blackListFile
wait
gawk -i inplace '!a[$0]++' $blacklist