mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
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:
parent
ce97896ffd
commit
e720de401d
1 changed files with 29 additions and 43 deletions
50
gravity.sh
50
gravity.sh
|
@ -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,12 +72,25 @@ 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.
|
|
||||||
if [ -f ${adListFile} ]; then
|
|
||||||
#User has disabled one or more default lists
|
#User has disabled one or more default lists
|
||||||
echo -n "::: Changes to default list detected. Reading adlists.list..."
|
echo -n "::: Pulling source lists into range..."
|
||||||
sources=()
|
sources=()
|
||||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
|
@ -88,33 +101,6 @@ gravity_collapse() {
|
||||||
fi
|
fi
|
||||||
done < ${adListFile}
|
done < ${adListFile}
|
||||||
echo " done!"
|
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.
|
||||||
|
|
Loading…
Reference in a new issue