vmstan / gravity-sync

๐Ÿ’ซ The easy way to synchronize the DNS configuration of two Pi-hole 5.x instances.
https://vmstan.com/gravity-sync/
GNU General Public License v3.0
2.27k stars 119 forks source link

Docker Pi Hole User and Group UID #417

Closed sudo-kraken closed 1 hour ago

sudo-kraken commented 7 months ago

I cant update my UID and GID to use for each pi hole instance as they run as non standard ID's i.e primary = 1000 and 988 and Secondary runs on 1000 and 997

Is there a way to update this ?

sudo-kraken commented 7 months ago

I ask as when gravity sync updates the secondary with changes it then makes my databases read only as the user can no longer write to them.

sudo-kraken commented 7 months ago

I have to exec in and manually alter it with chmod commands for the pihole user, it may be better to alter gravity sync to use names for users and not ID's ?

vmstan commented 7 months ago

https://github.com/vmstan/gravity-sync/wiki/Hidden-Figures

LOCAL_FILE_OWNER and REMOTE_FILE_OWNER are probably what you're looking for.

sudo-kraken commented 7 months ago

found it thank you :)

sudo-kraken commented 7 months ago

Sorry to reopen this but even with these set it is setting the user to 33 on dnsmasq.d folder and the files within to 0 (root) where is it getting 33 from this is also the case on /etc/pihole with it being 33 and only 1 or two files set to 999.

vmstan commented 7 months ago

This is using the stock Pi-hole Docker containers?

sudo-kraken commented 7 months ago

Yes standard official containers

On Tue, Dec 12, 2023 at 17:28, Michael Stanclift @.***(mailto:On Tue, Dec 12, 2023 at 17:28, Michael Stanclift < wrote:

This is using the stock Pi-hole Docker containers?

โ€” Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you modified the open/close state.Message ID: @.***>

Jarsky commented 7 months ago

I also just noticed that my Pi-Hole database is getting Read-Only now too I also use the standard docker container and i have a user "pihole:pihole" (1003:1003)

I updated gravity-sync gravity-sync update

Edited the conf (/etc/gravity-sync/gravity-sync.conf) with these variables

LOCAL_FILE_OWNER='1003:1003' REMOTE_FILE_OWNER='1003:1003'

Changed the ownership on my PiHoles

sudo chown -R pihole:pihole /opt/pihole

Restarted both the Pi-Holes

Added a Domain successfully through the UI and ran a manual sync

gravity-sync push

dns1:~$ gravity-sync push
โˆž Initializing Gravity Sync (4.0.5)
โœ“ Loading gravity-sync.conf
โœ“ Detecting local Pi-hole installation
โœ“ Detecting remote Pi-hole installation
โœ“ Gravity Sync remote peer is configured
โœ“ Evaluating arguments: PUSH
ยป Remote target ubuntu@192.168.1.xxx
โœ“ Validating pathways to Pi-hole
โœ“ Validating pathways to DNSMASQ
โœ“ Hashing the remote Gravity Database
โœ“ Comparing to the local Gravity Database
! Differences detected in the Gravity Database
โœ“ Hashing the remote DNS Records
โœ“ Comparing to the local DNS Records
โœ“ Comparing to the local DNS Records
โœ“ Hashing the remote DNS CNAMEs
โœ“ Comparing to the local DNS CNAMEs
! Static DHCP Addresses not detected on the local Pi-hole
! Replication of Pi-hole settings is required
โœ“ Performing backup of remote Gravity Database
โœ“ Performing backup of local Gravity Database
โœ“ Checking Gravity Database copy integrity
โœ“ Pushing the local Gravity Database
โœ“ Setting file ownership on Gravity Database
โœ“ Setting file permissions on Gravity Database
โœ“ Performing backup of remote DNS Records
โœ“ Performing backup of local DNS Records
โœ“ Pushing the local DNS Records
โœ“ Setting file ownership on DNS Records
โœ“ Setting file permissions on DNS Records
โœ“ Performing backup of remote DNS CNAMEs
โœ“ Performing backup of local DNS CNAMEs
โœ“ Pushing the local DNS CNAMEs
โœ“ Setting file ownership on DNS CNAMEs
โœ“ Setting file permissions on DNS CNAMEs
โœ“ Updating remote FTLDNS configuration
โœ“ Reloading remote FTLDNS services
โ€บ Performing replicator diagnostics
โœ“ Rehashing the remote Gravity Database
โœ“ Recomparing to local Gravity Database
โœ“ Rehashing the remote DNS Records
โœ“ Recomparing to local DNS Records
โœ“ Recomparing to local DNS Records
โœ“ Rehashing the remote DNS CNAMEs
โœ“ Recomparing to local DNS CNAMEs
! Static DHCP Addresses not detected on the local Pi-hole
โœ“ Saving updated data hashes
โœ“ Sending hashes to Gravity Sync peer
โœ“ Setting permissions on remote hashing files
โœ“ Logging successful PUSH
โˆž Gravity Sync PUSH completed after 137 seconds

The ownership on my database files has changed again..but its working now; so not really sure whats going on

-rw-rw-r-- 1 systemd-coredump ubuntu 96100352 Dec 23 11:50 pihole-FTL.db

Jarsky commented 7 months ago

Overnight it went back to Read-Only. A Straight reboot helped, so not sure if this is more of a PiHole Docker issue, more than a gravity-sync one...

Edit: Resolved by using the PIHOLE_UID and PIHOLE_GID environment variables in the Environment Variables in the Pi-Hole docker container. Set them to my 'pihole' user that the container is running as on my Docker host and now the database stops going Read-only. I guess something changed as I never needed that before.

vmstan commented 1 hour ago

Effective July 26, 2024, this project has been retired. Thank you for your use and enthusiasm for a project that began as a few lines of bash in a Slack channel and envolved into something far more complex, and used by many thousands of Pi-hole enthusiasts over the last four years.