Friday, February 28, 2020

Update: maintaining the pi-hole HA pair

In an earlier post, I shared how I got pi-hole working in my environment, thanks to a number of posts on a reddit thread. Since then, I've been living with the setup and tweaking my configuration a bit.

This post documents one of the tweaks that might be useful for others...

If you're using the method documented by Panja0, you know that there's a script in the pi-hole distribution (gravity.sh) that must be edited in order to synchronize files between the nodes of the HA pair. Well, he reminds you in the tutorial that it'll need to be re-edited every time you update pi-hole, or the synchronization won't occur.

As you might guess, I didn't remember when I updated a week ago, and couldn't understand why my settings weren't getting synchronized. So I went back to the post, reviewed my settings, and face-palmed myself when I discovered my oversight. I had failed to re-edit gravity.sh

After I did the necessary edits, I realized that, even if I'd remembered about it, I'd still need to refer to the original post to get the right command line, etc., for the edits.

I didn't want to spend the time to figure out how to trigger a script to make the update for me upon a pi-hole update, but I sure could figure out the script to do the correct updates!

I mean... come on: what better use of automation than to use a script to a) check to see if the update has already been performed, and b) if not, perform the update?

#!/bin/bash
# make sure the pihole-gemini script is being run by gravity.sh

GEMINI='su -c /usr/local/bin/pihole-gemini - <gemini user>'
GRAVITY=/opt/pihole/gravity.sh

TRIGGER=$(sed -e '$!{h;d;}' -e x $GRAVITY)
if [ "$TRIGGER" != "$GEMINI" ]
then
        # insert the gemini commandline before the last line of the script
        sed -i "$ i$GEMINI" $GRAVITY
fi

If you decide to use the script, just make sure that you make any necessary modifications for the first two script variables to match your installation. You also need it on both nodes of your HA pair!

In my setup, I'm saving this script in the /etc/scripts directory, which I'm using for other "keepalived" scripts. I'll remember to run it next time I update pi-hole, and that's all I'll need to recall!

21 comments:

  1. Thank you for sharing, and nice articles you have here buy fakenotes online moreover the admin of this site has really worked hard for all this once more thanks for sharing your articles.

    ReplyDelete
  2. Thank you for your analysis.
    Looking forward to reading more of your posts.
    I hope to give something back and help others like you aided me

    Watch No Time to Die Online Free

    ReplyDelete
  3. Rumah pods merupakan sebuah toko yang menyediakan berbagai keperluan terkait rokok elektrik jenis pod vape. Anda dapat menemukan berbagai jenis pods seperti JUUL, NCIG, Druga Lyfe, hingga Zeal serta kelengkapan lainnya dalam satu tempat, yaitu RUMAHPODS.

    Apa itu Pod System?
    Sensasi yang didapatkan saat menghisap rokok biasa dan pods hampir sama. Hanya saja, pods dirancang lebih cerdas dan ringkas dengan meminimalisir pembakaran. Pods sebagai rokok elektrik terhindar dari 7.000 senyawa kimia yang dapat memicu kanker serta penyakit paru-paru lainnya.


    ReplyDelete
  4. I didn't want to spendbuy-tripadvisor-reviews the time to figure out how to trigger a script to make the update for me upon a pi-hole update, but I sure could figure out the script to do the correct updates!

    ReplyDelete
  5. Alizeh Shah Scandal Biography Age Dramas Pictures Family Alizeh Shah is a Pakistani on-screen character who began her profession in 2018 with the show Ishq Tamasha. Alizeh Shah was immediately seen by the watchers and makers the same due to her attractive features as well as in view of her ability.
    Read More

    ReplyDelete
  6. Thanks for sharing such informative article. Check latest cooler buying guide on here

    ReplyDelete
  7. Thank you for sharing, and nice articles you have here buy weed online moreover the admin of this site has really worked hard for all this once more thanks for sharing your articles.

    ReplyDelete
  8. Thank you for sharing, and nice articles you have here buy painkillers online moreover the admin of this site has really worked hard for all this once more thanks for sharing your articles.

    ReplyDelete