From 9ce84714cde4a970c54eff783e7d9044307ddde1 Mon Sep 17 00:00:00 2001
From: Dan Schaper <dan.schaper@pi-hole.net>
Date: Thu, 2 May 2019 18:08:10 -0700
Subject: [PATCH 1/9] Update cryptocoin addresses

We no longer have access to the old coinbase account. Updating to new Coinbase Commerce account.
---
 README.md | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/README.md b/README.md
index c0f413ca..98a28a93 100644
--- a/README.md
+++ b/README.md
@@ -61,10 +61,7 @@ Make no mistake: **your support is absolutely vital to help keep us innovating!*
 Sending a donation using our links below is **extremely helpful** in offsetting a portion of our monthly expenses:
 
 - <img src="https://pi-hole.github.io/graphics/Badges/paypal-badge-black.svg" width="24" height="24" alt="PP"/> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY">Donate via PayPal</a><br/>
-- <img src="https://pi-hole.github.io/graphics/Badges/bitcoin-badge-black.svg" width="24" height="24" alt="BTC"/> [Bitcoin](https://commerce.coinbase.com/checkout/fb7facaf-bebd-46be-bb77-b358f4546763): <code>
-3MDPzjXu2hjw5sGLJvKUi1uXbvQPzVrbpF</code></br>
-- <img src="https://pi-hole.github.io/graphics/Badges/bitcoin-badge-black.svg" width="24" height="24" alt="BTC"/> [Bitcoin Cash](https://commerce.coinbase.com/checkout/fb7facaf-bebd-46be-bb77-b358f4546763): <code>qzqsz4aju2eecc6uhs7tus4vlwhhela24sdruf4qp5</code></br>
-- <img src="https://pi-hole.github.io/graphics/Badges/ethereum-badge-black.svg" width="24" height="24" alt="BTC"/> [Ethereum](https://commerce.coinbase.com/checkout/fb7facaf-bebd-46be-bb77-b358f4546763): <code>0x79d4e90A4a0C732819526c93e21A3F1356A2FAe1</code>
+- <img src="https://pi-hole.github.io/graphics/Badges/bitcoin-badge-black.svg" width="24" height="24" alt="BTC"/> [Bitcoin, Bitcoin Cash, Ethereum, Litecoin](https://commerce.coinbase.com/checkout/dd304d04-f324-4a77-931b-0db61c77a41b)
 
 ### Alternative support
 If you'd rather not [donate](https://pi-hole.net/donate/) (_which is okay!_), there are other ways you can help support us:

From b6700924b23a580a5286d8af343e205ae2d807d5 Mon Sep 17 00:00:00 2001
From: Mcat12 <newtoncat12@yahoo.com>
Date: Mon, 17 Jun 2019 16:13:31 -0700
Subject: [PATCH 2/9] Fix uninstall causing 403 errors and not removing
 packages

The 403 lighttpd errors were caused by removing the lighttpd config
directory and not removing lighttpd itself. This caused a subsequent
Pi-hole reinstall to not have all of the required lighttpd config files.

The error while removing packages was caused by combining arguments into
a string instead of listing each argument.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
---
 automated install/uninstall.sh | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index 732fc246..8e5c5455 100755
--- a/automated install/uninstall.sh	
+++ b/automated install/uninstall.sh	
@@ -80,7 +80,7 @@ removeAndPurge() {
                 case ${yn} in
                     [Yy]* )
                         echo -ne "  ${INFO} Removing ${i}...";
-                        ${SUDO} "${PKG_REMOVE} ${i}" &> /dev/null;
+                        ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null;
                         echo -e "${OVER}  ${INFO} Removed ${i}";
                         break;;
                     [Nn]* ) echo -e "  ${INFO} Skipped ${i}"; break;;
@@ -132,12 +132,15 @@ removeNoPurge() {
     fi
 
     if package_check lighttpd > /dev/null; then
-        ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
-        echo -e "  ${TICK} Removed lighttpd"
-    else
-        if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
+        if [[ -f /etc/lighttpd/lighttpd.conf.orig ]]; then
             ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
         fi
+
+        if [[ -f /etc/lighttpd/external.conf ]]; then
+            ${SUDO} rm /etc/lighttpd/external.conf
+        fi
+
+        echo -e "  ${TICK} Removed lighttpd configs"
     fi
 
     ${SUDO} rm -f /etc/dnsmasq.d/adList.conf &> /dev/null

From 951732fc1b07823e8f7c6b4cbfd28f753f1a8e50 Mon Sep 17 00:00:00 2001
From: Mcat12 <newtoncat12@yahoo.com>
Date: Mon, 17 Jun 2019 16:28:55 -0700
Subject: [PATCH 3/9] Use an array for PKG_REMOVE

Fixes shellcheck warning.

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
---
 automated install/uninstall.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index 8e5c5455..1f58b887 100755
--- a/automated install/uninstall.sh	
+++ b/automated install/uninstall.sh	
@@ -55,13 +55,13 @@ fi
 # Compatability
 if [ -x "$(command -v apt-get)" ]; then
     # Debian Family
-    PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
+    PKG_REMOVE=("${PKG_MANAGER}" -y remove --purge)
     package_check() {
         dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
     }
 elif [ -x "$(command -v rpm)" ]; then
     # Fedora Family
-    PKG_REMOVE="${PKG_MANAGER} remove -y"
+    PKG_REMOVE=("${PKG_MANAGER}" remove -y)
     package_check() {
         rpm -qa | grep "^$1-" > /dev/null
     }
@@ -80,7 +80,7 @@ removeAndPurge() {
                 case ${yn} in
                     [Yy]* )
                         echo -ne "  ${INFO} Removing ${i}...";
-                        ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null;
+                        ${SUDO} "${PKG_REMOVE}" "${i}" &> /dev/null;
                         echo -e "${OVER}  ${INFO} Removed ${i}";
                         break;;
                     [Nn]* ) echo -e "  ${INFO} Skipped ${i}"; break;;

From 974bba4a45427e628165e6e229984b810dcec2de Mon Sep 17 00:00:00 2001
From: Mcat12 <newtoncat12@yahoo.com>
Date: Mon, 17 Jun 2019 16:30:26 -0700
Subject: [PATCH 4/9] Fix PKG_REMOVE array usage

Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
---
 automated install/uninstall.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index 1f58b887..2d6837b4 100755
--- a/automated install/uninstall.sh	
+++ b/automated install/uninstall.sh	
@@ -80,7 +80,7 @@ removeAndPurge() {
                 case ${yn} in
                     [Yy]* )
                         echo -ne "  ${INFO} Removing ${i}...";
-                        ${SUDO} "${PKG_REMOVE}" "${i}" &> /dev/null;
+                        ${SUDO} "${PKG_REMOVE[@]}" "${i}" &> /dev/null;
                         echo -e "${OVER}  ${INFO} Removed ${i}";
                         break;;
                     [Nn]* ) echo -e "  ${INFO} Skipped ${i}"; break;;

From ecc49318f06e7bbfa868053904f736737f109ac6 Mon Sep 17 00:00:00 2001
From: RamSet <RamSet@gmail.com>
Date: Mon, 24 Jun 2019 12:38:03 -0600
Subject: [PATCH 5/9] Fixed MIME related issue present in lighttpd/1.4.53

Signed-off-by: RamSet <RamSet@gmail.com>
---
 advanced/lighttpd.conf.debian | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian
index d9c4a110..73833caa 100644
--- a/advanced/lighttpd.conf.debian
+++ b/advanced/lighttpd.conf.debian
@@ -44,9 +44,19 @@ static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
 compress.cache-dir          = "/var/cache/lighttpd/compress/"
 compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )
 
+mimetype.assign   = ( ".png"  => "image/png",
+                      ".jpg"  => "image/jpeg",
+                      ".jpeg" => "image/jpeg",
+                      ".html" => "text/html",
+                      ".css" => "text/css; charset=utf-8",
+                      ".js" => "application/javascript",
+                      ".json" => "application/json",
+                      ".txt"  => "text/plain",
+                      ".svg"  => "image/svg+xml" )
+
 # default listening port for IPv6 falls back to the IPv4 port
 include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
-include_shell "/usr/share/lighttpd/create-mime.assign.pl"
+#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
 
 # Prevent Lighttpd from enabling Let's Encrypt SSL for every blocked domain
 #include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

From b5af125be6fcda97d4d0381e99c1edb0e5423606 Mon Sep 17 00:00:00 2001
From: RamSet <RamSet@gmail.com>
Date: Tue, 25 Jun 2019 10:06:37 -0600
Subject: [PATCH 6/9] Removed line

Signed-off-by: RamSet <RamSet@gmail.com>
---
 advanced/lighttpd.conf.debian | 1 -
 1 file changed, 1 deletion(-)

diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian
index 73833caa..47bdbee0 100644
--- a/advanced/lighttpd.conf.debian
+++ b/advanced/lighttpd.conf.debian
@@ -56,7 +56,6 @@ mimetype.assign   = ( ".png"  => "image/png",
 
 # default listening port for IPv6 falls back to the IPv4 port
 include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
-#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
 
 # Prevent Lighttpd from enabling Let's Encrypt SSL for every blocked domain
 #include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

From d5e8f1a781bd21caec692b40949fb3af436c5c07 Mon Sep 17 00:00:00 2001
From: DL6ER <dl6er@dl6er.de>
Date: Wed, 26 Jun 2019 18:20:36 +0200
Subject: [PATCH 7/9] Add 10 seconds timeout to the sqlite3 command that writes
 tables to the gravity database. This prevents gravity from failing when the
 database file is locked for a short time.

Signed-off-by: DL6ER <dl6er@dl6er.de>
---
 gravity.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gravity.sh b/gravity.sh
index 1fe2b4e3..1c142ffd 100755
--- a/gravity.sh
+++ b/gravity.sh
@@ -129,7 +129,7 @@ database_table_from_file() {
   # Store domains in database table specified by ${table}
   # Use printf as .mode and .import need to be on separate lines
   # see https://unix.stackexchange.com/a/445615/83260
-  output=$( { printf ".mode csv\\n.import \"%s\" %s\\n" "${inputfile}" "${table}" | sqlite3 "${gravityDBfile}"; } 2>&1 )
+  output=$( { printf ".timeout 10000\\n.mode csv\\n.import \"%s\" %s\\n" "${inputfile}" "${table}" | sqlite3 "${gravityDBfile}"; } 2>&1 )
   status="$?"
 
   if [[ "${status}" -ne 0 ]]; then

From acee97916e3d9b22a8afb81230303c9a90a745a3 Mon Sep 17 00:00:00 2001
From: Andreas Kurth <github@akurth.de>
Date: Sun, 30 Jun 2019 08:02:51 +0200
Subject: [PATCH 8/9] Fix pihole manpage to match code.

The dry-run argument to pihole -up is "--check-only", not "--checkonly".

Signed-off-by: Andreas Kurth <github@akurth.de>
---
 manpages/pihole.8 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/manpages/pihole.8 b/manpages/pihole.8
index bd7d0933..b3008563 100644
--- a/manpages/pihole.8
+++ b/manpages/pihole.8
@@ -35,7 +35,7 @@ pihole -g\fR
 .br
 \fBpihole\fR \fB-l\fR (\fBon|off|off noflush\fR)
 .br
-\fBpihole -up \fR[--checkonly]
+\fBpihole -up \fR[--check-only]
 .br
 \fBpihole -v\fR [-p|-a|-f] [-c|-l|-hash]
 .br

From 04abcb71f62acb12c60f79de61db510e29fcb42c Mon Sep 17 00:00:00 2001
From: MMotti <matthew.w.motti@gmail.com>
Date: Wed, 3 Jul 2019 13:04:57 +0100
Subject: [PATCH 9/9] Fix potential invalid result for pihole -q

Signed-off-by: MMotti <matthew.w.motti@gmail.com>
---
 advanced/Scripts/query.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh
index 42ea4395..b7edaccf 100755
--- a/advanced/Scripts/query.sh
+++ b/advanced/Scripts/query.sh
@@ -41,7 +41,7 @@ scanList(){
 		# Iterate through each regexp and check whether it matches the domainQuery
 		# If it does, print the matching regexp and continue looping
 		# Input 1 - regexps | Input 2 - domainQuery
-		"regex" ) awk 'NR==FNR{regexps[$0]}{for (r in regexps)if($0 ~ r)print r}' \
+		"regex" ) awk 'NR==FNR{regexps[$0];next}{for (r in regexps)if($0 ~ r)print r}' \
 					<(echo "${lists}") <(echo "${domain}") 2>/dev/null;;
 		*       ) grep -i "${esc_domain}" ${lists} /dev/null 2>/dev/null;;
     esac