Created
July 12, 2018 04:35
-
-
Save venam/97a06e563161693d109b9d31152bab0b to your computer and use it in GitHub Desktop.
hosts block autofetcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# fetch the new block list | |
wget 'https://v.firebog.net/hosts/lists.php?type=all' -O list_all | |
# reset the old hosts directory | |
rm -r all_hosts | |
mkdir all_hosts | |
# read the file and download into the all_hosts directory | |
while read a; do | |
wget -P all_hosts "$a" | |
done < list_all | |
# fill the all_blocks file with the fixed up lines of all the hosts files | |
rm all_blocks | |
for a in $(command ls -1 all_hosts); do | |
sed -f fix_host.sed "all_hosts/$a" >> all_blocks | |
done | |
# sort and uniq it | |
sed -f fix_host.sed all_blocks | sort | uniq > all_blocks.uniq | |
mv all_blocks.uniq all_blocks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^#/d | |
/^\s*$/d | |
s/\s\+/ /g | |
s/0.0.0.0/127.0.0.1/ | |
/^127.0.0.1/!d | |
s/[ \t]*$// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment