Shell script to syncronize a secondary pi-hole server with a primary pi-hole server. It downloads blacklist.txt, whitelist.txt and regex.list from the primary, updates local files and runs updateGravity on the secondary.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
david e9fead4bd9 fixed an issue with pihole detection in cron 2 years ago
LICENSE Add LICENSE 2 years ago
README.md updated/fixed uninstall instructions 2 years ago
synchole.sh fixed an issue with pihole detection in cron 2 years ago

README.md

synchole

Shell script to syncronize a SLAVE pi-hole server with a MASTER pi-hole server. It downloads blacklist.txt, whitelist.txt and regex.list from the MASTER, updates local files and runs updateGravity on the SLAVE.

Setup

  1. Login via SSH to the MASTER server.

  2. Create symlinks for all files you want to be able to sync within the webroot of the MASTER pihole.

cd /var/www/html
sudo mkdir synchole
cd synchole
sudo ln -s /etc/pihole/whitelist.txt .
sudo ln -s /etc/pihole/blacklist.txt .
sudo ln -s /etc/pihole/regex.list .
  1. Login via SSH to the SLAVE server.

  2. Install wget and synchole on the SLAVE server.

sudo apt-get update
sudo apt-get install wget
sudo wget https://socialg.it/david/synchole/raw/master/synchole.sh -O /usr/bin/synchole
sudo chmod +x /usr/bin/synchole
  1. Configure the synchole script to your liking.
sudo vim /usr/bin/synchole

The config section is at the top of the script.

  1. Create a cron job for synchole on the SLAVE server.
sudo crontab -e

Example cronjob: */5 * * * * /usr/bin/synchole (this runs synchole every 5 minutes)

  1. Repeat steps 3 through 6 for additional SLAVE servers.

  2. Happy syncholeing!

Update

  1. To update synchole login via SSH to the SLAVE server.

  2. Run the following commands (again) on the SLAVE server.

sudo wget https://socialg.it/david/synchole/raw/master/synchole.sh -O /usr/bin/synchole
sudo chmod +x /usr/bin/synchole

Uninstall

  1. To uninstall synchole login via SSH to the SLAVE server.

  2. Run the following command on the SLAVE server.

sudo rm /usr/bin/synchole
  1. Login via SSH to the MASTER server.

  2. Run the following command on the MASTER server.

sudo rm -r /var/www/html/synchole
  1. Enjoy inconsistent states between your servers. ;-)

Resources