Merge pull request #2354 from realtebo/development

Create adlist file while running unattended setup
This commit is contained in:
Mark Drobnak 2018-08-16 11:26:07 -04:00 committed by GitHub
commit eb8e4496b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1087,8 +1087,15 @@ chooseBlocklists() {
# For each choice available,
for choice in ${choices}
do
# Set the values to true
case ${choice} in
appendToListsFile choice
done
}
# Accept a string parameter, it must be one of the default lists
# This function allow to not duplicate code in chooseBlocklists and
# in installDefaultBlocklists
appendToListsFile() {
case $1 in
StevenBlack ) echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >> "${adlistFile}";;
MalwareDom ) echo "https://mirror1.malwaredomains.com/files/justdomains" >> "${adlistFile}";;
Cameleon ) echo "http://sysctl.org/cameleon/hosts" >> "${adlistFile}";;
@ -1097,7 +1104,23 @@ chooseBlocklists() {
DisconAd ) echo "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" >> "${adlistFile}";;
HostsFile ) echo "https://hosts-file.net/ad_servers.txt" >> "${adlistFile}";;
esac
done
}
# Used only in unattended setup
# If there is already the adListFile, we keep it, else we create it using all default lists
installDefaultBlocklists() {
# In unattended setup, could be useful to use userdefined blocklist.
# If this file exists, we avoid overriding it.
if [[ -f "${adlistFile}" ]]; then
return;
fi
appendToListsFile StevenBlack
appendToListsFile MalwareDom
appendToListsFile Cameleon
appendToListsFile ZeusTracker
appendToListsFile DisconTrack
appendToListsFile DisconAd
appendToListsFile HostsFile
}
# Check if /etc/dnsmasq.conf is from pi-hole. If so replace with an original and install new in .d directory
@ -2391,6 +2414,8 @@ main() {
# Let the user decide if they want query logging enabled...
setLogging
else
# Setup adlist file if not exists
installDefaultBlocklists
# Source ${setupVars} to use predefined user variables in the functions
source ${setupVars}
fi