PiHole HA Sync

Script to run on a primary PiHole server to sync blocklist database and custom local DNS entries to a secondary server.

Make sure to setup sshkeys to allow user on primary server to login to secondary server.

Then run this script in the cron every 15-30 minutes.

# HA Sync from PiHolePri to PiHoleSec
*/15 * * * * /root/pi-ha-sync.sh >> /var/log/pi-ha-sync.log 2>&1
#!/usr/bin/env bash

sshuser=pi
pisecondary=10.10.10.10
sshkey=/root/.ssh/id.pi
filelist="gravity.db custom.list"

piping=$(timeout 0.2 ping -c1 ${pisecondary} &> /dev/null && echo "0" || echo "1")
if [ "${piping}" -eq 0 ]; then
  cd /etc/pihole/
  ssh -i ${sshkey} ${sshuser}@${pisecondary} 'if [ ! -d ~/piholepri ]; then mkdir ~/piholepri; fi'
  scp -q -i ${sshkey} ${filelist} ${sshuser}@${pisecondary}:~/piholepri
  ssh -i ${sshkey} ${sshuser}@${pisecondary} "sudo cp ~/piholepri/* /etc/pihole"
  ssh -i ${sshkey} ${sshuser}@${pisecondary} "pihole restartdns reload-lists"
else
  echo "${pisecondary} is not available."
fi

Network Caller ID

Who uses a land line phone now-a-days. Well I do, but I added a digital touch to it by connecting a USB modem to a Raspberry Pi and running NCID. This allow me to push CallerID notifications using Pushover to my phone/laptop/desktop. Now I know when a telemarketer calls even when I’m out of the house.

Gitea

This is my main code repository in my house. While I maintain good coding practices and keep credentials out of the code, I also keep the code local so I can make changes offline. I really like that Gitea is developed in GoLang. I also installed a Dark Theme and changed the link colors too.

Home Inventory

I wanted something to keep track of all the devices I had on my network. While installing Zabbix, I had to install MariaDB (MySQL), so I used that database to house the inventory of devices. This also uses PHP, jQuery and DataTables on the front end and Bash, Python and GO on the backend.

The scripts connect to and parse the data from my routers DHCP server logs. Then match that to DNS (running on 2 PiHoles), looks up the OUI of the MAC address for manufacturer and scans it’s ports looking for SSH, HTTP or HTTPS.

PiZabbix

https://linuxhint.com/install_zabbix_raspberry_pi/

While investigating the use of Zabbix for my department to use, I found a lot of uses for it in my house. I have it monitoring many of my IOT devices found on my Hardware Projects page. At first I was going to install it in a VM on my FreeNAS server, but I found installing it on a Raspberry Pi easier and would take the iops away from my main storage array. I’m currently in the process of updating to a Raspberry Pi 4 and better USB 3.0 storage.