Pi-hole Port Update Helper

I’m a big fan of Pi-hole. Due to my instance running on the same Raspberry Pi as Home Assistant I have it configured for a different port than the default 80. Each time I run an update for Pi-hole I manually edit the config file and restart the service, because the update scripts reset the port. I finally whipped up a script to take care of it.

sudo cp /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.old
sudo sed -i -e 's/= 80/= 8081/g' /etc/lighttpd/lighttpd.conf
sudo systemctl restart lighttpd

Blog in a Box Paparazzi

wapi-512Happy Pi Day! I figured I better post something Raspberry Pi related today…

This weekend I played around with Blog in a Box which was recently released by our Tinker team at Automattic.

A quick and easy way of putting WordPress onto a Raspberry Pi.

BIAB ships with modules to use the Raspberry Pi camera and SenseHAT. I hadn’t used my Pi camera yet and had a fun idea to hack around with.


The camera module allows you to take a photo on a schedule by setting a period of minutes, hours, or days between each photo. I wanted to have a little more fun, so I wired some other electronics up to a Raspberry Pi Zero and wrote a little Python program.

The first electronic element was a simple button. Press it and a picture is taken. Next up was a photocell (light sensor). When the room quickly changes from dark to light, it’ll take a picture. Since the Pi doesn’t have analog inputs, I went with a neat technique of measuring the sensor as a resistor used to ‘fill up’ a capacitor. The last element was an ultrasonic sensor I haven’t used yet either. It measures the distance to an object in front of it, so I’m kind of using it as a motion detector. Walk in front of the sensor and a picture is snapped. Due to mismatched voltages on the PI’s GPIO and the output signal of the rangefinder, I had to use some resistors to create a voltage divider circuit.

To create visual feedback I wired up an LED for each of these 3 components. When one of the components triggers a photo, the associated LED lights up until the process is complete.

I named it Blog in a Box Paparazzi. Of course the code and wiring info are available on GitHub. Should be easy to adjust if you have other sensors, buttons, switches, or whatever you want to trigger photos. Let me know if you try something different.

How To Install Pi-Hole on a Raspberry Pi Zero

Mom gets what Mom wants. The necessary parts came in to build Mom’s Raspberry Pi-Hole server, so I thought I’d take the extra time to keep track of every step, trying to make it as easy and low-cost as I could. This meant not attaching a monitor or keyboard through the entire process. Hopefully someone will benefit from this guide. It looks long and scary, but I tried to be as thorough as possible. Nothing here is particularly difficult if you can follow directions.

Note: these instructions are for using a Mac.

Step 1: Buy the Parts

At a minimum, I recommend:

Make sure the microSD card is class 10, because it’s faster and don’t be afraid to go for 16GB since they are so cheap. Adafruit sells a budget pack which includes everything above except the WiFi adapter. If you don’t want to use WiFi, you could get something like this Ethernet Hub and USB Hub.

I also recommend some type of case. It may be small, but it’s still a computer with electrical components. 😉 I bought the Adafruit Raspberry Pi Zero Case this time around, but I don’t like how loose the GPIO slot cover is. Three cases I use with my own Zeros and like (ordered by preference) much better are:

Shouldn’t cost more than $50.

Step 2: Install the Operating System (Raspbian)

  • Download Raspbian.
  • Download ApplePi Baker and extract the app from the zip file.
  • Plug the SD card into your computer, probably via a USB card reader or SD card adapter.
  • Launch ApplePi Baker. It’ll ask for your MacOS user password.
  • Select your SD card on the left side.
  • Uncheck Auto eject after successful restore.
  • Click the Restore Backup button and browse to select the Raspbian file you downloaded. Once selected it’ll start writing to your SD card. It should look like this…


  • While that is running, save this sample wpa_supplicant.conf file. If you set Format to All Files you can remove the .txt without MacOS adding it back on. This file needs to be named exactly wpa_supplicant.conf.


  • Open the file in TextEdit. Replace YOUR_SSID with the name of your WiFi network and YOUR_PASSWORD with your WiFi password. Save the file.
  • When ApplePi Baker is finished click OK and quit the app.
  • Copy the updated wpa_supplicant.conf file to the SD card.
  • Open the Mac’s Terminal app.
  • Type cd /Volumes/boot and hit Enter.
  • Type touch ssh and hit Enter.


  • Quit Terminal.
  • Eject the SD card via Finder and then remove it from your computer.

Step 3: Prepare the Raspberry Pi

  • Slide the SD card into the slot on your Pi Zero.
  • Put the Pi Zero into your case if you have one.
  • Plug the USB cable and WiFi adapter into the micro USB port labeled USB. Hint: it’s not the one on the end. You should end up with it looking like this…


  • Now you’re ready for power! Plug your power supply into the other micro USB port (nearest to the edge) and into your power source.
  • You should see some activity from the green light (labeled ACT) near the power connection.


Step 4: Access the Pi

If you did the second half of step 2 correct, the Pi should have been able to connect to your WiFi network. Give it 1-2 minutes to go through the entire boot process.

  • Open the Mac Terminal app again.
  • Type ssh pi@raspberrypi.local and hit Enter.
    • Using the IP address for SSH may work better for you ssh pi@ but you’ll need to find it in the DHCP list in your router’s admin.
  • If everything worked, it’ll connect and you will be asked if you want to continue. Type yes and hit Enter.
  • Then you’ll be asked for the password. Type raspberry (you won’t see any characters on the screen) and hit Enter. This should log you in and set you at the command prompt…


Step 5: Run Software Updates

  • Type sudo apt-get update and hit Enter.
  • When it finished you’ll be back on the command prompt. Type sudo apt-get upgrade and hit Enter. When it asks Do you want to continue? [Y/n], type y, hit Enter, and wait.

Step 6: Configure Your Pi

  • Type sudo raspi-config and hit Enter.
  • Any mouse/trackpad devices won’t work in here, so get used to the tab, Enter, and arrow keys.
  • Change User Password. Remember it!
  • Choose Advanced Options and then Hostname. Set a new “computer name” instead of the default raspberrypi. When you’re done and back to the main menu, select Finish and perform the reboot.
  • You’ll lose your connection when the Pi is rebooting. Terminal will send you back to the local Mac command prompt. Wait 1-2 minutes.

Step 7: Install Pi-Hole

  • Connect back to your Pi via ssh, but this time you need to use your new hostname. For example if I had set nickspi the new command I would type is ssh pi@nickspi.local. You’ll be prompted again to continue and enter the password. Do both.
  • Type curl -sSL https://install.pi-hole.net | bash and hit Enter.
  • Accept all of the defaults when prompted during installation.
  • At the end it’ll give you a bunch of information on an Installation Complete! screen. Make note of the IP address and admin password. Hit Enter.
  • It’ll do a little more and then send you back to the command prompt along with providing all of the information again.
  • Change the password right away with the command:
    pihole -a -p PASSWORD_YOU_WANT_TO_USE

Step 8: Configure Your Router

Step 9: Profit

Enjoy your mostly ad-free browsing and faster network!

Step 10: Notes

It’s not advised to unplug the Pi from power when it’s running. You could corrupt the SD card. SSH in (you’re a pro by now) and issue the shutdown command:

sudo shutdown -h now

Wait about a minute before unplugging power (make sure the activity light has been off at least a few seconds). You can also issue a restart command if you need to:

sudo reboot

Periodically it’s a good idea to update the software:

sudo apt-get update
sudo apt-get upgrade
pihole -up

With all of that said… if you plan to run anything else on this server, I recommend going with more power, probably a Raspberry Pi 3 Model B. The Zero I originally used wasn’t enough to handle Home Assistant and Homebridge running on the same machine.

Quickie: 01/09/2008 10:41:35pm

Dedicated server is finally setup. First admin ended up getting swamped and put off my work for a few weeks until finally referring me elsewhere. I’ll tackle it tomorrow and start getting the sites ready for transfer.