One file to rule them all, same functionality (made changes and want to go back to default? Delete your adlists.list)

This commit is contained in:
Adam Warner 2017-03-31 19:16:09 +01:00
parent ce97896ffd
commit e720de401d
No known key found for this signature in database
GPG key ID: 7C062498C7FA6E49

View file

@ -29,8 +29,8 @@ EOM
PIHOLE_COMMAND="/usr/local/bin/pihole" PIHOLE_COMMAND="/usr/local/bin/pihole"
adListFile=/etc/pihole/adlists.list adListFile=/etc/pihole/adlists.list
adListDefault=/etc/pihole/adlists.default adListDefault=/etc/pihole/adlists.default #being deprecated
adListCustom=/etc/pihole/adlists.custom adListRepoDefault=/etc/.pihole/adlists.default
whitelistScript="${PIHOLE_COMMAND} -w" whitelistScript="${PIHOLE_COMMAND} -w"
whitelistFile=/etc/pihole/whitelist.txt whitelistFile=/etc/pihole/whitelist.txt
blacklistFile=/etc/pihole/blacklist.txt blacklistFile=/etc/pihole/blacklist.txt
@ -72,49 +72,35 @@ fi
########################### ###########################
# collapse - begin formation of pihole # collapse - begin formation of pihole
gravity_collapse() { gravity_collapse() {
#New Logic:
# Does /etc/pihole/adlists.list exist? If so leave it alone
# If not, cp /etc/.pihole/adlists.default /etc/pihole/adlists.list
# Read from adlists.list
#The following two blocks will sort out any missing adlists in the /etc/pihole directory, and remove legacy adlists.default
if [ -f ${adListDefault} ] && [ -f ${adListFile} ]; then
rm ${adListDefault}
fi
if [ ! -f ${adListFile} ]; then
cp ${adListRepoDefault} ${adListFile}
fi
echo "::: Neutrino emissions detected..." echo "::: Neutrino emissions detected..."
echo ":::" echo ":::"
#Decide if we're using a custom ad block list, or defaults. #User has disabled one or more default lists
if [ -f ${adListFile} ]; then echo -n "::: Pulling source lists into range..."
#User has disabled one or more default lists sources=()
echo -n "::: Changes to default list detected. Reading adlists.list..." while IFS= read -r line || [[ -n "$line" ]]; do
sources=() #Do not read commented out or blank lines
while IFS= read -r line || [[ -n "$line" ]]; do if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
#Do not read commented out or blank lines echo "" > /dev/null
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then else
echo "" > /dev/null sources+=(${line})
else fi
sources+=(${line}) done < ${adListFile}
fi echo " done!"
done < ${adListFile}
echo " done!"
else
#
echo -n "::: No changes to default list detected. Reading adlists.default..."
sources=()
while IFS= read -r line || [[ -n "$line" ]]; do
#Do not read commented out or blank lines
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
echo "" > /dev/null
else
sources+=(${line})
fi
done < ${adListDefault}
echo " done!"
fi
if [ -f ${adListCustom} ]; then
echo -n "Custom additional lists detected. Reading adlists.custom..."
while IFS= read -r line || [[ -n "$line" ]]; do
#Do not read commented out or blank lines
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
echo "" > /dev/null
else
sources+=(${line})
fi
done < ${adListCustom}
echo " done!"
fi
} }
# patternCheck - check to see if curl downloaded any new files. # patternCheck - check to see if curl downloaded any new files.