Auto Update Pi-Hole


#1
crontab -e

add this line to the bottom

0 7 * * * pihole -up

Error while updating Pi Hole
#2

Is it safe to run dist-upgrade, wouldn’t that mess up the dns if a new kernel breaks things?


#3

Yeah, I don’t think any of the devs would suggest doing that. The additional pihole commands are also not necessary as pihole -g and -f already run automatically.


#4

So stick with the regular apt-get upgrade to keep all packages updated?


#5

so i am not allowed to upgrade my raspberry pi (“https://www.raspberrypi.org/documentation/raspbian/updating.md”) to the latest version because it can break pihole?


#6

Updating Raspian shouldn’t break pi.hole, you can run it on other distros too afaik


#7

We did have some issues when users upgraded from Wheezy to Jessie. For now, I would say upgrade at your own discretion and if you do run into problems, we’re around to help.


#8

Disclaimer: Don’t run this code unless you understand it.

Hi,

Here is my script to update pihole running RASPBIAN.

#!/bin/sh
sudo apt update
sudo apt -yf dist-upgrade
sudo apt-get -y --purge autoremove
sudo apt-get autoclean
pihole -g -up
pihole -up

The sudo commands update all the packages and remove any old items. The "-g up"updates gravity first and then I update the pihole subsystems later with “-up”. One other note, I’ve found on many pihole systems that you have to run the installer and perform an upgrade in order to get the FTL code.


#9

This is the cron at /etc/cron.d/pihole, installed with pihole:

pi@raspberrypi:~ $ cat /etc/cron.d/pihole
# Pi-hole: A black hole for Internet advertisements
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
# Network-wide ad blocking via your own hardware.
#
# Updates ad sources every week
#
# This file is copyright under the latest version of the EUPL.
# Please see LICENSE file for your rights under this license.
#
#
#
# This file is under source-control of the Pi-hole installation and update
# scripts, any changes made to this file will be overwritten when the softare
# is updated or re-installed. Please make any changes to the appropriate crontab
# or other cron file snippets.

# Pi-hole: Update the ad sources once a week on Sunday at a random time in the
#          early morning. Download any updates from the adlists
3 4   * * 7   root    PATH="$PATH:/usr/local/bin/" pihole updateGravity

# Pi-hole: Update Pi-hole! Uncomment to enable auto update
#30 2    * * 7   root    PATH="$PATH:/usr/local/bin/" pihole updatePihole

# Pi-hole: Flush the log daily at 00:00
#          The flush script will use logrotate if available
#          parameter "once": logrotate only once (default is twice)
#          parameter "quiet": don't print messages
00 00   * * *   root    PATH="$PATH:/usr/local/bin/" pihole flush once quiet

@reboot root /usr/sbin/logrotate /etc/pihole/logrotate

# Pi-hole: Grab local version and branch every 10 minutes
*/10 *  * * *   root    PATH="$PATH:/usr/local/bin/" pihole updatechecker local

# Pi-hole: Grab remote version every 24 hours
28 15  * * *   root    PATH="$PATH:/usr/local/bin/" pihole updatechecker remote
@reboot root    PATH="$PATH:/usr/local/bin/" pihole updatechecker remote reboot

Can someone explain why the line to update pihole (#30 2 * * 7 root PATH="$PATH:/usr/local/bin/" pihole updatePihole) is even in there, since uncommenting that line will cause an overwrite the moment an update is actually performed (since the update will overwrite this file, as stated earlier in the file).


#10

The intention is that the user will uncomment it if they want it to auto-update, but it looks like we didn’t take into account that it would also be updated! You can always copy the line to a different cron file.


#11

If I’ve understood the thread correctly, there currently isn’t an official/intended way to enable auto-updating of pi-hole (that lasts more than one update)?


#12

Auto update is not recommended. You will get a lot of postings for help at the same time, now it get distributed a bit, and at the same time, time is won to Bugfix Code.

Pinhole is like a steamroller on files that you have changed, which you should not have changed.


#13

So yes, but that’s a good thing :slight_smile: