From ddd6f3dbe592e3fe14085bacab7a749626d75a89 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 16 Dec 2017 13:55:52 +0000 Subject: [PATCH 1/9] Grammar changes. Lets not work out programmatically whether we need to pluralise a word. It's not needed. Signed-off-by: Adam Warner --- gravity.sh | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gravity.sh b/gravity.sh index a7e24d0a..273980c7 100755 --- a/gravity.sh +++ b/gravity.sh @@ -69,7 +69,7 @@ fi # Determine if DNS resolution is available before proceeding gravity_DNSLookup() { - local lookupDomain="pi.hole" plural="" + local lookupDomain="pi.hole" # Determine if $localList does not exist if [[ ! -e "${localList}" ]]; then @@ -111,11 +111,10 @@ gravity_DNSLookup() { # Ensure DNS server is given time to be resolvable 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 [[ "${secs:-}" -eq 0 ]] && break - [[ "${secs:-}" -ne 1 ]] && plural="s" - echo -ne "${OVER} ${INFO} Waiting up to ${secs} second${plural} before continuing..." + echo -ne "${OVER} ${INFO} Time until retry: ${secs}" : $((secs--)) sleep 1 done @@ -406,7 +405,7 @@ gravity_Filter() { # Format $parsedMatter line total as currency num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${parsedMatter}")") 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" echo -ne " ${INFO} ${str}..." @@ -415,20 +414,19 @@ gravity_Filter() { # Format $preEventHorizon line total as currency 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 gravity_WhitelistBLD() { - local uniqDomains plural="" str + local uniqDomains echo "" # Create array of unique $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}..." # Whitelist $uniqDomains @@ -439,7 +437,7 @@ gravity_WhitelistBLD() { # Whitelist user-defined domains gravity_Whitelist() { - local num plural="" str + local num str if [[ ! -f "${whitelistFile}" ]]; then echo -e " ${INFO} Nothing to whitelist!" @@ -447,8 +445,7 @@ gravity_Whitelist() { fi num=$(wc -l < "${whitelistFile}") - [[ "${num}" -ne 1 ]] && plural="s" - str="Whitelisting ${num} domain${plural}" + str="Number of whitelisted domains: ${num}" echo -ne " ${INFO} ${str}..." # Print everything from preEventHorizon into whitelistMatter EXCEPT domains in $whitelistFile @@ -459,12 +456,11 @@ gravity_Whitelist() { # Output count of blacklisted domains and wildcards gravity_ShowBlockCount() { - local num plural + local num if [[ -f "${blacklistFile}" ]]; then num=$(printf "%'.0f" "$(wc -l < "${blacklistFile}")") - plural=; [[ "${num}" -ne 1 ]] && plural="s" - echo -e " ${INFO} Blacklisted ${num} domain${plural}" + echo -e " ${INFO} Number of blacklisted domains: ${num}" fi if [[ -f "${wildcardFile}" ]]; then @@ -473,8 +469,7 @@ gravity_ShowBlockCount() { if [[ -n "${IPV4_ADDRESS}" ]] && [[ -n "${IPV6_ADDRESS}" ]];then num=$(( num/2 )) fi - plural=; [[ "${num}" -ne 1 ]] && plural="s" - echo -e " ${INFO} Wildcard blocked ${num} domain${plural}" + echo -e " ${INFO} Number of wildcard blocked domains: ${num}" fi } From 5ecc46d85bc4b03dbce2ad3e2fa85a811b5e1929 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 16 Dec 2017 14:03:12 +0000 Subject: [PATCH 2/9] Accidentally too many spaces Signed-off-by: Adam Warner --- gravity.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index 273980c7..299acdb5 100755 --- a/gravity.sh +++ b/gravity.sh @@ -405,7 +405,7 @@ gravity_Filter() { # Format $parsedMatter line total as currency num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${parsedMatter}")") echo -e "${OVER} ${TICK} ${str} - ${INFO} Number of domains being pulled in by gravity: ${COL_BLUE}${num}${COL_NC}" + ${INFO} Number of domains being pulled in by gravity: ${COL_BLUE}${num}${COL_NC}" str="Removing duplicate domains" echo -ne " ${INFO} ${str}..." @@ -414,7 +414,7 @@ gravity_Filter() { # Format $preEventHorizon line total as currency num=$(printf "%'.0f" "$(wc -l < "${piholeDir}/${preEventHorizon}")") - echo -e " ${INFO} Number of unique domains trapped in the Event Horizon: ${COL_BLUE}${num}${COL_NC}" + echo -e " ${INFO} Number of unique domains trapped in the Event Horizon: ${COL_BLUE}${num}${COL_NC}" } # Whitelist unique blocklist domain sources From 2d3906450ae2bf7ec0c4638bd0f6284a4d08c9ec Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 18 Dec 2017 20:14:53 +0000 Subject: [PATCH 3/9] add back in str local var, and change ticks to info on whitelist lines Signed-off-by: Adam Warner --- gravity.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index 299acdb5..40debd61 100755 --- a/gravity.sh +++ b/gravity.sh @@ -419,7 +419,7 @@ gravity_Filter() { # Whitelist unique blocklist domain sources gravity_WhitelistBLD() { - local uniqDomains + local uniqDomains str echo "" @@ -432,7 +432,7 @@ gravity_WhitelistBLD() { # Whitelist $uniqDomains "${PIHOLE_COMMAND}" -w -nr -q ${uniqDomains[*]} &> /dev/null - echo -e "${OVER} ${TICK} ${str}" + echo -e "${OVER} ${INFO} ${str}" } # Whitelist user-defined domains @@ -451,7 +451,7 @@ gravity_Whitelist() { # Print everything from preEventHorizon into whitelistMatter EXCEPT domains in $whitelistFile 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 From b30b3f3aebe1e14fa09b931b6c2d7cef3aa770a1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 18 Dec 2017 22:05:58 +0100 Subject: [PATCH 4/9] Update DNSSEC trust anchor Signed-off-by: DL6ER --- advanced/Scripts/webpage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 07bc160f..f09ce22e 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -152,7 +152,7 @@ ProcessDNSSettings() { if [[ "${DNSSEC}" == true ]]; then echo "dnssec -trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5 +trustanchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D " >> "${dnsmasqconfig}" fi From 8a243c5872a8892d7a0aea400e4b2242854c83a4 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 18 Dec 2017 22:09:19 +0100 Subject: [PATCH 5/9] Insert also old trust anchor Signed-off-by: DL6ER --- advanced/Scripts/webpage.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index f09ce22e..c25d036b 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -152,6 +152,7 @@ ProcessDNSSettings() { if [[ "${DNSSEC}" == true ]]; then echo "dnssec +trustanchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5 trustanchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D " >> "${dnsmasqconfig}" fi From cfca367eef93d8bdd7e12b6544644064ce92f867 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 18 Dec 2017 22:14:28 +0100 Subject: [PATCH 6/9] Quickly verified in dnsmasq's source code: It has to be "trust-anchor" (with "-") Signed-off-by: DL6ER --- advanced/Scripts/webpage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index c25d036b..c5081fd5 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -152,8 +152,8 @@ ProcessDNSSettings() { if [[ "${DNSSEC}" == true ]]; then echo "dnssec -trustanchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5 -trustanchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D +trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5 +trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D " >> "${dnsmasqconfig}" fi From 3c04dbb4edffb203ab40f6aefce905c8dfdc0b7e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 21 Dec 2017 12:33:08 +0100 Subject: [PATCH 7/9] Update remote version at 17:59 as well as on reboot Signed-off-by: DL6ER --- advanced/pihole.cron | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 87a2bd3c..50a9a914 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -33,4 +33,5 @@ */10 * * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker local # 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 From be0c4574450849810cc23c4f809b8a4f442ae6ed Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 21 Dec 2017 12:37:09 +0100 Subject: [PATCH 8/9] Sleep 30 seconds after reboot to be sure that the system is ready Signed-off-by: DL6ER --- advanced/Scripts/updatecheck.sh | 4 ++++ advanced/pihole.cron | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/updatecheck.sh b/advanced/Scripts/updatecheck.sh index f8ce59dd..04f210a2 100755 --- a/advanced/Scripts/updatecheck.sh +++ b/advanced/Scripts/updatecheck.sh @@ -39,6 +39,10 @@ git describe --long --dirty --tags || return 1 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_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)")" diff --git a/advanced/pihole.cron b/advanced/pihole.cron index 50a9a914..64837197 100644 --- a/advanced/pihole.cron +++ b/advanced/pihole.cron @@ -34,4 +34,4 @@ # Pi-hole: Grab remote version every 24 hours 59 17 * * * root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote -@reboot root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote +@reboot root PATH="$PATH:/usr/local/bin/" pihole updatechecker remote reboot From f89f7ecd3ea0fd72aa1e403828cfb572b9fcc410 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 21 Dec 2017 12:42:47 +0100 Subject: [PATCH 9/9] Randomize GitHub API update check time Signed-off-by: DL6ER --- automated install/basic-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 527e2d9f..832fd77b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1368,7 +1368,9 @@ installCron() { # Copy the cron file over from the local repo cp ${PI_HOLE_LOCAL_REPO}/advanced/pihole.cron /etc/cron.d/pihole # 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}" }