From 901cb44f5e2fe688cde871e1304ae1805c519c73 Mon Sep 17 00:00:00 2001
From: Nate <nate@ubiquisoft.com>
Date: Sat, 26 Mar 2016 16:50:05 -0500
Subject: [PATCH] Added /etc/.pihole/ and /var/log/*pihole* to uninstall as
 well as fixed missing call to removeNoPurge.

---
 automated install/basic-install.sh | 26 +++++++++++++-------------
 automated install/uninstall.sh     | 14 +++++++++++---
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index fe385fbb..2f910c03 100755
--- a/automated install/basic-install.sh	
+++ b/automated install/basic-install.sh	
@@ -72,19 +72,19 @@ fi
 # fi
 
 ####### FUNCTIONS ##########
-###All credit for the below function goes to http://fitnr.com/showing-a-bash-spinner.html
-spinner() {
-	local pid=$1
-
-	spin='-\|/'
-	i=0
-	while $SUDO kill -0 "$pid" 2>/dev/null
-	do
-		i=$(( (i+1) %4 ))
-		printf "\b%s" "{$spin:$i:1}"
-		sleep .1
-	done
-	printf "\b"
+spinner()
+{
+    local pid=$1
+    local delay=0.75
+    local spinstr='|/-\'
+    while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
+        local temp=${spinstr#?}
+        printf " [%c]  " "$spinstr"
+        local spinstr=$temp${spinstr%"$temp"}
+        sleep $delay
+        printf "\b\b\b\b\b\b"
+    done
+    printf "    \b\b\b\b"
 }
 
 backupLegacyPihole() {
diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh
index 5ddaa0ac..9c47ce44 100755
--- a/automated install/uninstall.sh	
+++ b/automated install/uninstall.sh	
@@ -34,7 +34,10 @@ function removeAndPurge {
 
 	# Remove dependency config files
 	echo "Removing dnsmasq config files..."
-	$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig &> /dev/null
+	$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
+
+	# Call removeNoPurge to remove PiHole specific files
+	removeNoPurge
 }
 
 function removeNoPurge {
@@ -45,8 +48,10 @@ function removeNoPurge {
 	$SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null
 
 	# If the web directory is empty after removing these files, then the parent html folder can be removed.
-	if [[ ! "$(ls -A /var/www/html)" ]]; then
-    		$SUDO rm -rf /var/www/html &> /dev/null
+	if [ -d "/var/www/html" ]; then
+		if [[ ! "$(ls -A /var/www/html)" ]]; then
+    			$SUDO rm -rf /var/www/html &> /dev/null
+		fi
 	fi
 
 	# Attempt to preserve backwards compatibility with older versions
@@ -73,7 +78,10 @@ function removeNoPurge {
 	$SUDO rm /usr/local/bin/chronometer.sh &> /dev/null
 	$SUDO rm /usr/local/bin/whitelist.sh &> /dev/null
 	$SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null
+	$SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null
+	$SUDO rm -rf /var/log/*pihole* &> /dev/null
 	$SUDO rm -rf /etc/pihole/ &> /dev/null
+	$SUDO rm -rf /etc/.pihole/ &> /dev/null
 
 }