From a3b3a7a34dfbef0eb73c915829bca18aedfca700 Mon Sep 17 00:00:00 2001
From: Adam Warner <promofaux@users.noreply.github.com>
Date: Mon, 1 Aug 2016 21:43:13 +0100
Subject: [PATCH] Add option for uploading debug log to termbin

---
 advanced/Scripts/piholeDebug.sh | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh
index 36ae15bc..ec08c984 100755
--- a/advanced/Scripts/piholeDebug.sh
+++ b/advanced/Scripts/piholeDebug.sh
@@ -337,17 +337,27 @@ function dumpPiHoleLog {
 
 # Anything to be done after capturing of pihole.log terminates
 function finalWork {
-	echo "::: Finshed debugging!"
-	TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999)
+        echo "::: Finshed debugging!"
+    echo "::: The degug log can be uploaded to Termbin.com for easier sharing."
+        read -r -p "::: Would you like to upload the log? [y/N] " response
+    case $response in
+        [yY][eE][sS]|[yY])
+            TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999)
+            ;;
+        *)
+            echo "::: Log will NOT be uploaded to Termbin."
+            ;;
+    esac
 
-	# Check if termbin.com is reachable. When it's not, point to local log instead
-	if [ -n "$TERMBIN" ]
-	then
-		echo "::: Debug log can be found at : $TERMBIN"
-	else
-		echo "::: Debug log can be found at : /var/log/pihole_debug.log"
-	fi
+        # Check if termbin.com is reachable. When it's not, point to local log instead
+        if [ -n "$TERMBIN" ]
+        then
+                echo "::: Debug log can be found at : $TERMBIN"
+        else
+                echo "::: Debug log can be found at : /var/log/pihole_debug.log"
+        fi
 }
+
 trap finalWork EXIT
 
 ### Method calls for additional logging ###