Skip to content

Fix gravity.sh -- Alpine / Docker specific issue #1767

@karolkania

Description

@karolkania

Versions

  • Core version is v6.0.4 (Latest: v6.0.4)
  • Web version is v6.0.1 (Latest: v6.0.1)
  • FTL version is v6.0.2 (Latest: v6.0.3)

Platform

  • OS and version: Alpine
  • Platform: Docker

Expected behavior

Update Gravity (list of blocked domains) should update the database

Actual behavior / bug

Update Gravity (list of blocked domains) does not happen

Steps to reproduce

Steps to reproduce the behavior:

Add a proper list and go to /admin/gravity; click update.

Output:

  Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp. 
  [✓] DNS resolution is available

  [i] Neutrino emissions detected...

  [✓] Preparing new gravity database
  [✓] Creating new gravity databases
  [✓] Pulling blocklist source list into range
  [i] Using libz compression


  *** HERE's the bug ***
  [✗] Unable to write to /etc/pihole/listsCache
      Please run pihole -g as root

  [✓] Building tree
  [i] Number of gravity domains: 0 (0 unique domains)
  [i] Number of exact denied domains: 0
  [i] Number of regex denied filters: 0
  [i] Number of exact allowed domains: 0
  [i] Number of regex allowed filters: 0
  [✓] Optimizing database
  [✓] Swapping databases
  [✓] The old database remains available
  [✓] Cleaning up stray matter

  [✓] Done.



Not digging too deep, I was able to figure out that this is most likely related to differences between how the shell script is interpreted by Bash - on Alpine (Ash, not Bash) this seems to trigger unexpected results.

I've raised a quick PR -- pi-hole/pi-hole@a9650ae

and this is the script output after the fix is applied:

Gravity temporary directory does not exist or is not a writeable directory, falling back to /tmp. 
  [✓] DNS resolution is available

  [i] Neutrino emissions detected...

  [✓] Preparing new gravity database
  [✓] Creating new gravity databases
  [✓] Pulling blocklist source list into range
  [i] Using libz compression

directory_permissions: 775
saveLocation_permissions: 660
  [i] Target: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
  [✓] Status: No changes detected
  [✓] Parsed 127472 exact domains and 0 ABP-style domains (blocking, ignored 0 non-domain entries)

directory_permissions: 775
saveLocation_permissions: 664
  [i] Target: https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt
  [✓] Status: No changes detected
  [✓] Parsed 91588 exact domains and 0 ABP-style domains (blocking, ignored 0 non-domain entries)

  [✓] Building tree
  [i] Number of gravity domains: 219060 (131136 unique domains)
  [i] Number of exact denied domains: 0
  [i] Number of regex denied filters: 0
  [i] Number of exact allowed domains: 0
  [i] Number of regex allowed filters: 0
  [✓] Optimizing database
  [✓] Swapping databases
  [✓] The old database remains available
  [✓] Cleaning up stray matter

  [✓] Done.

This is a very Alpine specific fix, most likely won't work as expected on other distros / platforms. That said I was just trying to solve it quickly for my use-case, haven't been working on it to make the fix everything-agnostic.


Debug Token

  • URL:

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions