From c6ba03802f2fbad107a9f1b36416ff996e75542b Mon Sep 17 00:00:00 2001
From: WaLLy3K <WaLLy3K@users.noreply.github.com>
Date: Wed, 5 Jul 2017 17:18:21 +1000
Subject: [PATCH 1/5] Add "php5-sqlite" to dependencies

---
 automated install/basic-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 3c6b77af..0dd2ee48 100755
--- a/automated install/basic-install.sh	
+++ b/automated install/basic-install.sh	
@@ -122,7 +122,7 @@ if command -v apt-get &> /dev/null; then
   # #########################################
   INSTALLER_DEPS=(apt-utils dialog debconf dhcpcd5 git ${iproute_pkg} whiptail)
   PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget)
-  PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi)
+  PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-sqlite)
   LIGHTTPD_USER="www-data"
   LIGHTTPD_GROUP="www-data"
   LIGHTTPD_CFG="lighttpd.conf.debian"

From d0492898eb9bd244895fa90a8bc5cf12ba70a73c Mon Sep 17 00:00:00 2001
From: WaLLy3K <WaLLy3K@users.noreply.github.com>
Date: Wed, 5 Jul 2017 17:21:17 +1000
Subject: [PATCH 2/5] Add "php5-sqlite" to uninstall dependencies

---
 automated install/uninstall.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index 336bb953..eaf5a40b 100755
--- a/automated install/uninstall.sh	
+++ b/automated install/uninstall.sh	
@@ -45,7 +45,7 @@ if [ -x "$(command -v rpm)" ]; then
 		PKG_MANAGER="yum"
 	fi
 	PKG_REMOVE="${PKG_MANAGER} remove -y"
-	PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common git curl unzip wget findutils )
+	PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-sqlite git curl unzip wget findutils )
 	package_check() {
 		rpm -qa | grep ^$1- > /dev/null
 	}
@@ -56,7 +56,7 @@ elif [ -x "$(command -v apt-get)" ]; then
 	# Debian Family
 	PKG_MANAGER="apt-get"
 	PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
-	PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
+	PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common php5-sqlite git curl unzip wget )
 	package_check() {
 		dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
 	}

From 56f2ea3ec2d243076553b67774ca7c97c13e824a Mon Sep 17 00:00:00 2001
From: Adam Warner <adamw@rner.email>
Date: Wed, 16 Aug 2017 15:56:39 +0100
Subject: [PATCH 3/5] Add Fedora/Centos dependency

Signed-off-by: Adam Warner <adamw@rner.email>
---
 automated install/basic-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 0dd2ee48..31320182 100755
--- a/automated install/basic-install.sh	
+++ b/automated install/basic-install.sh	
@@ -153,7 +153,7 @@ elif command -v rpm &> /dev/null; then
   PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
   INSTALLER_DEPS=(dialog git iproute net-tools newt procps-ng)
   PIHOLE_DEPS=(bc bind-utils cronie curl dnsmasq findutils nmap-ncat sudo unzip wget)
-  PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli)
+  PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php php-common php-cli php-pdo)
   if ! grep -q 'Fedora' /etc/redhat-release; then
     INSTALLER_DEPS=("${INSTALLER_DEPS[@]}" "epel-release");
   fi

From 01cd056bcc661abb67799ad8dad28cc3d89fd327 Mon Sep 17 00:00:00 2001
From: Adam Warner <adamw@rner.email>
Date: Wed, 16 Aug 2017 16:27:50 +0100
Subject: [PATCH 4/5] Work out correct SQLITE version for php-sqlite

Signed-off-by: Adam Warner <adamw@rner.email>
---
 automated install/basic-install.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 31320182..b38f2827 100755
--- a/automated install/basic-install.sh	
+++ b/automated install/basic-install.sh	
@@ -119,10 +119,16 @@ if command -v apt-get &> /dev/null; then
   else
     phpVer="php5"
   fi
+  # We also need the correct version for `php-sqlite` (which differs across distros)
+  if ${PKG_MANAGER} install --dry-run ${phpVer}-sqlite3 > /dev/null 2>&1; then
+    phpSqlite="sqlite3"
+  else
+    phpSqlite="sqlite"
+  fi
   # #########################################
   INSTALLER_DEPS=(apt-utils dialog debconf dhcpcd5 git ${iproute_pkg} whiptail)
   PIHOLE_DEPS=(bc cron curl dnsmasq dnsutils iputils-ping lsof netcat sudo unzip wget)
-  PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-sqlite)
+  PIHOLE_WEB_DEPS=(lighttpd ${phpVer}-common ${phpVer}-cgi ${phpVer}-${phpSqlite})
   LIGHTTPD_USER="www-data"
   LIGHTTPD_GROUP="www-data"
   LIGHTTPD_CFG="lighttpd.conf.debian"

From 64f29120c87961bc786276453ac0e14a12968e71 Mon Sep 17 00:00:00 2001
From: Adam Warner <adamw@rner.email>
Date: Thu, 17 Aug 2017 19:43:07 +0100
Subject: [PATCH 5/5] indent nested function in basic-install.sh fix dependency
 in uninstall.sh

Signed-off-by: Adam Warner <adamw@rner.email>
---
 automated install/basic-install.sh | 32 +++++++++++++++---------------
 automated install/uninstall.sh     | 18 ++++++++---------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index b5010299..902c6483 100755
--- a/automated install/basic-install.sh	
+++ b/automated install/basic-install.sh	
@@ -177,22 +177,22 @@ if command -v apt-get &> /dev/null; then
   # The DNS server user
   DNSMASQ_USER="dnsmasq"
 
-# A function to check...
-test_dpkg_lock() {
-    # An iterator used for counting loop iterations
-    i=0
-    # fuser is a program to show which processes use the named files, sockets, or filesystems
-    # So while the command is true
-    while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
-      # Wait half a second
-      sleep 0.5
-      # and increase the iterator
-      ((i=i+1))
-    done
-    # Always return success, since we only return if there is no
-    # lock (anymore)
-    return 0
-  }
+  # A function to check...
+  test_dpkg_lock() {
+      # An iterator used for counting loop iterations
+      i=0
+      # fuser is a program to show which processes use the named files, sockets, or filesystems
+      # So while the command is true
+      while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
+        # Wait half a second
+        sleep 0.5
+        # and increase the iterator
+        ((i=i+1))
+      done
+      # Always return success, since we only return if there is no
+      # lock (anymore)
+      return 0
+    }
 
 # If apt-get is not found, check for rpm to see if it's a Red Hat family OS
 elif command -v rpm &> /dev/null; then
diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index eaf5a40b..08869b2e 100755
--- a/automated install/uninstall.sh	
+++ b/automated install/uninstall.sh	
@@ -45,7 +45,7 @@ if [ -x "$(command -v rpm)" ]; then
 		PKG_MANAGER="yum"
 	fi
 	PKG_REMOVE="${PKG_MANAGER} remove -y"
-	PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-sqlite git curl unzip wget findutils )
+	PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common php-pdo git curl unzip wget findutils )
 	package_check() {
 		rpm -qa | grep ^$1- > /dev/null
 	}
@@ -94,12 +94,12 @@ removeAndPurge() {
 	# Remove dnsmasq config files
 	${SUDO} rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
   echo -e "  ${TICK} Removing dnsmasq config files"
-  
+
 	# Take care of any additional package cleaning
 	echo -ne "  ${INFO} Removing & cleaning remaining dependencies..."
 	package_cleanup &> /dev/null
   echo -e "${OVER}  ${TICK} Removed & cleaned up remaining dependencies"
-  
+
 	# Call removeNoPurge to remove Pi-hole specific files
 	removeNoPurge
 }
@@ -145,7 +145,7 @@ removeNoPurge() {
 			${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
 		fi
 	fi
-  
+
 	${SUDO} rm /etc/dnsmasq.d/adList.conf &> /dev/null
 	${SUDO} rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
 	${SUDO} rm -rf /var/log/*pihole* &> /dev/null
@@ -156,23 +156,23 @@ removeNoPurge() {
 	${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null
 	${SUDO} rm /etc/sudoers.d/pihole &> /dev/null
   echo -e "  ${TICK} Removed config files"
-  
+
   # Remove FTL
   if command -v pihole-FTL &> /dev/null; then
     echo -ne "  ${INFO} Removing pihole-FTL..."
-    
+
     if [[ -x "$(command -v systemctl)" ]]; then
       systemctl stop pihole-FTL
     else
       service pihole-FTL stop
     fi
-    
+
     ${SUDO} rm /etc/init.d/pihole-FTL
     ${SUDO} rm /usr/bin/pihole-FTL
-    
+
     echo -e "${OVER}  ${TICK} Removed pihole-FTL"
   fi
-  
+
 	# If the pihole user exists, then remove
 	if id "pihole" &> /dev/null; then
 		${SUDO} userdel -r pihole 2> /dev/null