From 7a243f890eaf8939ac9b73bf3ae823ba0167d772 Mon Sep 17 00:00:00 2001
From: DL6ER <derigs@ph1.uni-koeln.de>
Date: Fri, 16 Dec 2016 17:33:01 +0100
Subject: [PATCH 1/2] Backend for privacyMode on webUI

---
 advanced/Scripts/webpage.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh
index d07e5c94..135861df 100755
--- a/advanced/Scripts/webpage.sh
+++ b/advanced/Scripts/webpage.sh
@@ -212,6 +212,19 @@ SetDNSDomainName(){
 
 }
 
+SetPrivacyMode(){
+
+	# Remove setting from file (create backup setupVars.conf.bak)
+	sed -i.bak '/API_PRIVACY_MODE/d' /etc/pihole/setupVars.conf
+	# Save setting to file
+	if [[ "${args[2]}" == "true" ]] ; then
+		echo "API_PRIVACY_MODE=true" >> /etc/pihole/setupVars.conf
+	else
+		echo "API_PRIVACY_MODE=false" >> /etc/pihole/setupVars.conf
+	fi
+
+}
+
 case "${args[1]}" in
 	"-p" | "password"   ) SetWebPassword;;
 	"-c" | "celsius"    ) unit="C"; SetTemperatureUnit;;
@@ -227,6 +240,7 @@ case "${args[1]}" in
 	"layout"            ) SetWebUILayout;;
 	"-h" | "--help"     ) helpFunc;;
 	"domainname"        ) SetDNSDomainName;;
+	"privacymode"       ) SetPrivacyMode;;
 	*                   ) helpFunc;;
 esac
 

From 7320fc11d23cb332fbf66ca5dd80ae3fc8053ad4 Mon Sep 17 00:00:00 2001
From: Dan Schaper <dan.schaper@pi-hole.net>
Date: Tue, 27 Dec 2016 11:53:23 -0800
Subject: [PATCH 2/2] Check command -v directly, instead of subshelling out.

Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
---
 automated install/basic-install.sh | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 3bda5b58..cb51ba41 100755
--- a/automated install/basic-install.sh	
+++ b/automated install/basic-install.sh	
@@ -63,7 +63,7 @@ else
   echo ":::"
   echo "::: Detecting the presence of the sudo utility for continuation of this install..."
 
-  if [ -x "$(command -v sudo)" ]; then
+  if command -v sudo &> /dev/null; then
     echo "::: Utility sudo located."
     exec curl -sSL https://install.pi-hole.net | sudo bash "$@"
     exit $?
@@ -75,7 +75,7 @@ fi
 
 # Compatibility
 
-if [[ $(command -v apt-get) ]]; then
+if command -v apt-get &> /dev/null; then
   #Debian Family
   #############################################
   PKG_MANAGER="apt-get"
@@ -101,9 +101,9 @@ if [[ $(command -v apt-get) ]]; then
   package_check_install() {
     dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed" || ${PKG_INSTALL} "${1}"
   }
-elif [ $(command -v rpm) ]; then
+elif command -v rpm &> /dev/null; then
   # Fedora Family
-  if [ $(command -v dnf) ]; then
+  if command -v dnf &> /dev/null; then
     PKG_MANAGER="dnf"
   else
     PKG_MANAGER="yum"
@@ -421,7 +421,7 @@ setStaticIPv4() {
         echo "USERCTL=no"
       }> "${IFCFG_FILE}"
       ip addr replace dev "${PIHOLE_INTERFACE}" "${IPV4_ADDRESS}"
-      if [ -x "$(command -v nmcli)" ];then
+      if command -v nmcli &> /dev/null;then
         # Tell NetworkManager to read our new sysconfig file
         nmcli con load "${IFCFG_FILE}" > /dev/null
       fi
@@ -681,7 +681,7 @@ stop_service() {
   # Can softfail, as process may not be installed when this is called
   echo ":::"
   echo -n "::: Stopping ${1} service..."
-  if [ -x "$(command -v systemctl)" ]; then
+  if command -v systemctl &> /dev/null; then
     systemctl stop "${1}" &> /dev/null || true
   else
     service "${1}" stop &> /dev/null || true
@@ -694,7 +694,7 @@ start_service() {
   # This should not fail, it's an error if it does
   echo ":::"
   echo -n "::: Starting ${1} service..."
-  if [ -x "$(command -v systemctl)" ]; then
+  if command -v systemctl &> /dev/null; then
     systemctl restart "${1}" &> /dev/null
   else
     service "${1}" restart &> /dev/null
@@ -706,7 +706,7 @@ enable_service() {
   # Enable service so that it will start with next reboot
   echo ":::"
   echo -n "::: Enabling ${1} service to start on reboot..."
-  if [ -x "$(command -v systemctl)" ]; then
+  if command -v systemctl &> /dev/null; then
     systemctl enable "${1}" &> /dev/null
   else
     update-rc.d "${1}" defaults &> /dev/null
@@ -869,10 +869,10 @@ create_pihole_user() {
 
 configureFirewall() {
   # Allow HTTP and DNS traffic
-  if [ -x "$(command -v firewall-cmd)" ]; then
+  if command -v firewall-cmd &> /dev/null; then
     firewall-cmd --state &> /dev/null && ( echo "::: Configuring firewalld for httpd and dnsmasq.." && firewall-cmd --permanent --add-port=80/tcp && firewall-cmd --permanent --add-port=53/tcp \
     && firewall-cmd --permanent --add-port=53/udp && firewall-cmd --reload) || echo "::: FirewallD not enabled"
-  elif [ -x "$(command -v iptables)" ]; then
+  elif command -v iptables &> /dev/null; then
     echo "::: Configuring iptables for httpd and dnsmasq.."
     iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
     iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
@@ -954,7 +954,7 @@ updatePihole() {
 
 
 checkSelinux() {
-  if [ -x "$(command -v getenforce)" ]; then
+  if command -v getenforce &> /dev/null; then
     echo ":::"
     echo -n "::: SELinux Support Detected... Mode: "
     enforceMode=$(getenforce)