Quickly Enable/Disable Pi-Hole from your phone


#1

This has been asked about (and covered) a few times so I thought I’d add a $0.02 solution.

This assumes you’re running Android. Install Raspberry SSH Lite from the Android market and add/create these two scripts to any directory of choice on your RPi (don’t forget to chmod +x). I put them in /root.

Enable Pi-Hole

Disable Pi-Hole

In Raspberry SSH Lite add a button with the command sh /root/en-pihole.sh plus your SSH credentials. Save, then clone that button but point it to sh /root/dis-pihole.sh. That’s it. Pressing Disable will rename your pihole.conf file to .bak, effectively disabling ad-blocking. Enabling will reverse this.

Some caveats: I’m running these under root. Using sudo with a less privileged account is always a better choice. Also, this could be done with a single script but I’m lazy.

Screenshot 2016 03 15 11 48 31


#2

I thought about making a Pi-Hole specific app in the play store but running SSH commands is already easy as pi :slight_smile: Also, you can add buttons for scripts in /usr/local/bin to update the admin interface, flush stats, update adlists, etc.


#3

For whatever reason, renaming 01-pihole.conf does not consistently turn off ad blocking. I tested it with gravity.list however and it works mo betta :slight_smile:

#!/usr/bin/env bash

# Script to toggle ad-blocking on/off. Save in /usr/local/bin

list=/etc/pihole/gravity.list

if [[ -f $list ]];then
	mv $list $list.off
	systemctl restart dnsmasq
	echo "Ad-blocking disabled"
else
	mv $list.off $list
	systemctl restart dnsmasq
	echo "Ad-blocking enabled"
fi

#4

A post was split to a new topic: How to statically assign addresses to clients