Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (24 sloc) 1.09 KB
# Author:
# last update: 2018-10
# remove any old TMP_HOSTS that might have stuck around
rm ${TMP_HOSTS} 2> /dev/null
for URL in \
"" \
# filter out comment lines, empty lines, localhost...
# remove trailing comments, space( ,tab), empty line
# replace line to dnsmasq format
# remove carriage returns
# append the results to TMP_HOSTS
wget -4 --no-check-certificate -qO- "${URL}" | grep -v -e "^#" -e "^\s*$" -e "localhost" -e "broadcasthost" -e "ip6" -e "^;" -e "^@" -e "^:" -e "^[a-zA-Z]" \
| sed -E -e "s/#.*$//" -e "s/[[:space:]]*//g" -e "/^$/d" \
-e "s/^\/./" -e "s/\/./" -e "/^[0-9].*$/d" -e "s/$/\/" \
| tr -d "\r" >> ${TMP_HOSTS}
# remove duplicate hosts and save the real hosts file
sort ${TMP_HOSTS} | uniq > ${HOSTS}
rm ${TMP_HOSTS} 2> /dev/null
You can’t perform that action at this time.