mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #1863 from pi-hole/master
Sync with development branch
This commit is contained in:
commit
d43ad263ea
5 changed files with 24 additions and 21 deletions
|
@ -39,6 +39,10 @@ git describe --long --dirty --tags || return 1
|
||||||
|
|
||||||
if [[ "$2" == "remote" ]]; then
|
if [[ "$2" == "remote" ]]; then
|
||||||
|
|
||||||
|
if [[ "$3" == "reboot" ]]; then
|
||||||
|
sleep 30
|
||||||
|
fi
|
||||||
|
|
||||||
GITHUB_CORE_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/pi-hole/releases/latest' 2> /dev/null)")"
|
GITHUB_CORE_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/pi-hole/releases/latest' 2> /dev/null)")"
|
||||||
GITHUB_WEB_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/AdminLTE/releases/latest' 2> /dev/null)")"
|
GITHUB_WEB_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/AdminLTE/releases/latest' 2> /dev/null)")"
|
||||||
GITHUB_FTL_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/FTL/releases/latest' 2> /dev/null)")"
|
GITHUB_FTL_VERSION="$(json_extract tag_name "$(curl -q 'https://api.github.com/repos/pi-hole/FTL/releases/latest' 2> /dev/null)")"
|
||||||
|
|
|
@ -153,6 +153,7 @@ ProcessDNSSettings() {
|
||||||
if [[ "${DNSSEC}" == true ]]; then
|
if [[ "${DNSSEC}" == true ]]; then
|
||||||
echo "dnssec
|
echo "dnssec
|
||||||
trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
|
trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
|
||||||
|
trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D
|
||||||
" >> "${dnsmasqconfig}"
|
" >> "${dnsmasqconfig}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,5 @@
|
||||||
*/10 * * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker local
|
*/10 * * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker local
|
||||||
|
|
||||||
# Pi-hole: Grab remote version every 24 hours
|
# Pi-hole: Grab remote version every 24 hours
|
||||||
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote
|
59 17 * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote
|
||||||
|
@reboot root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote reboot
|
||||||
|
|
|
@ -1368,7 +1368,9 @@ installCron() {
|
||||||
# Copy the cron file over from the local repo
|
# Copy the cron file over from the local repo
|
||||||
cp ${PI_HOLE_LOCAL_REPO}/advanced/pihole.cron /etc/cron.d/pihole
|
cp ${PI_HOLE_LOCAL_REPO}/advanced/pihole.cron /etc/cron.d/pihole
|
||||||
# Randomize gravity update time
|
# Randomize gravity update time
|
||||||
sed -i "s/59 1/$((1 + RANDOM % 58)) $((3 + RANDOM % 2))/" /etc/cron.d/pihole
|
sed -i "s/59 1 /$((1 + RANDOM % 58)) $((3 + RANDOM % 2))/" /etc/cron.d/pihole
|
||||||
|
# Randomize update checker time
|
||||||
|
sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /etc/cron.d/pihole
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${TICK} ${str}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
33
gravity.sh
33
gravity.sh
|
@ -69,7 +69,7 @@ fi
|
||||||
|
|
||||||
# Determine if DNS resolution is available before proceeding
|
# Determine if DNS resolution is available before proceeding
|
||||||
gravity_DNSLookup() {
|
gravity_DNSLookup() {
|
||||||
local lookupDomain="pi.hole" plural=""
|
local lookupDomain="pi.hole"
|
||||||
|
|
||||||
# Determine if $localList does not exist
|
# Determine if $localList does not exist
|
||||||
if [[ ! -e "${localList}" ]]; then
|
if [[ ! -e "${localList}" ]]; then
|
||||||
|
@ -111,11 +111,10 @@ gravity_DNSLookup() {
|
||||||
|
|
||||||
# Ensure DNS server is given time to be resolvable
|
# Ensure DNS server is given time to be resolvable
|
||||||
secs="120"
|
secs="120"
|
||||||
echo -ne " ${INFO} Waiting up to ${secs} seconds before continuing..."
|
echo -ne " ${INFO} Time until retry: ${secs}"
|
||||||
until timeout 1 getent hosts "${lookupDomain}" &> /dev/null; do
|
until timeout 1 getent hosts "${lookupDomain}" &> /dev/null; do
|
||||||
[[ "${secs:-}" -eq 0 ]] && break
|
[[ "${secs:-}" -eq 0 ]] && break
|
||||||
[[ "${secs:-}" -ne 1 ]] && plural="s"
|
echo -ne "${OVER} ${INFO} Time until retry: ${secs}"
|
||||||
echo -ne "${OVER} ${INFO} Waiting up to ${secs} second${plural} before continuing..."
|
|
||||||
: $((secs--))
|
: $((secs--))
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
@ -406,7 +405,7 @@ gravity_Filter() {
|
||||||
# Format $parsedMatter line total as currency
|
# Format $parsedMatter line total as currency
|
||||||
num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${parsedMatter}")")
|
num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${parsedMatter}")")
|
||||||
echo -e "${OVER} ${TICK} ${str}
|
echo -e "${OVER} ${TICK} ${str}
|
||||||
${INFO} ${COL_BLUE}${num}${COL_NC} domains being pulled in by gravity"
|
${INFO} Number of domains being pulled in by gravity: ${COL_BLUE}${num}${COL_NC}"
|
||||||
|
|
||||||
str="Removing duplicate domains"
|
str="Removing duplicate domains"
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne " ${INFO} ${str}..."
|
||||||
|
@ -415,31 +414,30 @@ gravity_Filter() {
|
||||||
|
|
||||||
# Format $preEventHorizon line total as currency
|
# Format $preEventHorizon line total as currency
|
||||||
num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${preEventHorizon}")")
|
num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${preEventHorizon}")")
|
||||||
echo -e " ${INFO} ${COL_BLUE}${num}${COL_NC} unique domains trapped in the Event Horizon"
|
echo -e " ${INFO} Number of unique domains trapped in the Event Horizon: ${COL_BLUE}${num}${COL_NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Whitelist unique blocklist domain sources
|
# Whitelist unique blocklist domain sources
|
||||||
gravity_WhitelistBLD() {
|
gravity_WhitelistBLD() {
|
||||||
local uniqDomains plural="" str
|
local uniqDomains str
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Create array of unique $sourceDomains
|
# Create array of unique $sourceDomains
|
||||||
mapfile -t uniqDomains <<< "$(awk '{ if(!a[$1]++) { print $1 } }' <<< "$(printf '%s\n' "${sourceDomains[@]}")")"
|
mapfile -t uniqDomains <<< "$(awk '{ if(!a[$1]++) { print $1 } }' <<< "$(printf '%s\n' "${sourceDomains[@]}")")"
|
||||||
[[ "${#uniqDomains[@]}" -ne 1 ]] && plural="s"
|
|
||||||
|
|
||||||
str="Adding ${#uniqDomains[@]} blocklist source domain${plural} to the whitelist"
|
str="Number of blocklist source domains being added to the whitelist: ${#uniqDomains[@]}"
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne " ${INFO} ${str}..."
|
||||||
|
|
||||||
# Whitelist $uniqDomains
|
# Whitelist $uniqDomains
|
||||||
"${PIHOLE_COMMAND}" -w -nr -q ${uniqDomains[*]} &> /dev/null
|
"${PIHOLE_COMMAND}" -w -nr -q ${uniqDomains[*]} &> /dev/null
|
||||||
|
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${INFO} ${str}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Whitelist user-defined domains
|
# Whitelist user-defined domains
|
||||||
gravity_Whitelist() {
|
gravity_Whitelist() {
|
||||||
local num plural="" str
|
local num str
|
||||||
|
|
||||||
if [[ ! -f "${whitelistFile}" ]]; then
|
if [[ ! -f "${whitelistFile}" ]]; then
|
||||||
echo -e " ${INFO} Nothing to whitelist!"
|
echo -e " ${INFO} Nothing to whitelist!"
|
||||||
|
@ -447,24 +445,22 @@ gravity_Whitelist() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
num=$(wc -l < "${whitelistFile}")
|
num=$(wc -l < "${whitelistFile}")
|
||||||
[[ "${num}" -ne 1 ]] && plural="s"
|
str="Number of whitelisted domains: ${num}"
|
||||||
str="Whitelisting ${num} domain${plural}"
|
|
||||||
echo -ne " ${INFO} ${str}..."
|
echo -ne " ${INFO} ${str}..."
|
||||||
|
|
||||||
# Print everything from preEventHorizon into whitelistMatter EXCEPT domains in $whitelistFile
|
# Print everything from preEventHorizon into whitelistMatter EXCEPT domains in $whitelistFile
|
||||||
grep -F -x -v -f "${whitelistFile}" "${piholeDir}/${preEventHorizon}" > "${piholeDir}/${whitelistMatter}"
|
grep -F -x -v -f "${whitelistFile}" "${piholeDir}/${preEventHorizon}" > "${piholeDir}/${whitelistMatter}"
|
||||||
|
|
||||||
echo -e "${OVER} ${TICK} ${str}"
|
echo -e "${OVER} ${INFO} ${str}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output count of blacklisted domains and wildcards
|
# Output count of blacklisted domains and wildcards
|
||||||
gravity_ShowBlockCount() {
|
gravity_ShowBlockCount() {
|
||||||
local num plural
|
local num
|
||||||
|
|
||||||
if [[ -f "${blacklistFile}" ]]; then
|
if [[ -f "${blacklistFile}" ]]; then
|
||||||
num=$(printf "%'.0f" "$(wc -l < "${blacklistFile}")")
|
num=$(printf "%'.0f" "$(wc -l < "${blacklistFile}")")
|
||||||
plural=; [[ "${num}" -ne 1 ]] && plural="s"
|
echo -e " ${INFO} Number of blacklisted domains: ${num}"
|
||||||
echo -e " ${INFO} Blacklisted ${num} domain${plural}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "${wildcardFile}" ]]; then
|
if [[ -f "${wildcardFile}" ]]; then
|
||||||
|
@ -473,8 +469,7 @@ gravity_ShowBlockCount() {
|
||||||
if [[ -n "${IPV4_ADDRESS}" ]] && [[ -n "${IPV6_ADDRESS}" ]];then
|
if [[ -n "${IPV4_ADDRESS}" ]] && [[ -n "${IPV6_ADDRESS}" ]];then
|
||||||
num=$(( num/2 ))
|
num=$(( num/2 ))
|
||||||
fi
|
fi
|
||||||
plural=; [[ "${num}" -ne 1 ]] && plural="s"
|
echo -e " ${INFO} Number of wildcard blocked domains: ${num}"
|
||||||
echo -e " ${INFO} Wildcard blocked ${num} domain${plural}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue