u/oleksiiYo

Self-healing local mirror for HaGeZi lists while the GitHub repo is locked
▲ 41 r/pihole

Self-healing local mirror for HaGeZi lists while the GitHub repo is locked

Same as for everyone, my gravity updates broke when HaGeZi's repo got locked by GitHub fraud detection (again).

Instead of hand-swapping adlist URLs each time, I now point gravity at a local file and let a script keep it fresh from whichever official source is alive. So I thought I would share it if anyone finds it useful.

How it works:

  1. Tries GitHub → Codeberg (hagezi/mirror2) → GitLab (hagezi/mirror) → jsDelivr, in that order. GitHub first means it snaps back to canonical automatically once the repo is reinstated.
  2. Validates each download before replacing the local copy: min line count, [Adblock header, and ! Last modified: under 5 days — that last one rejects CDN caches serving stale copies of a dead origin.
  3. If all sources fail, it keeps the existing copy and logs it. Nothing gets wiped or silently goes stale.

https://preview.redd.it/nin8s30triih1.png?width=1260&format=png&auto=webp&s=e243db03458cc7dde8110bd4143e67827ca1b571

Setup:

  1. Drop the script in /usr/local/bin/hagezi-fetch.sh, chmod +x, run once.
  2. Add adlist file:///var/lib/pihole-mirror/hagezi-pro.txt; disable (don't delete) the old GitHub entry.
  3. Install the cron job from the gist — fetch, then pihole updateGravity, joined with ; on purpose so gravity still runs off the last good copy if every mirror is down.
  4. pihole updateGravity and check the domain count.

Logs via logger -t hagezi — journalctl -t hagezi shows which source was used and why others were rejected.

Script + cron: https://gist.github.com/okalentiev/694c6f5a56043e8b8d542dc1b5afa006

I use Pro; swap the filename in the URLs for other lists. Note the GitLab mirror dropped NRD/DGA lists in June (size limits).

Built with the help of Claude Code; the setup and script were tested end-to-end on my Pi-hole v6 before posting.

reddit.com
u/oleksiiYo — 11 days ago