jacklul / pihole-updatelists

Update Pi-hole's lists from remote sources easily
MIT License
1.42k stars 82 forks source link

Attaching to running docker container? #124

Closed DieSchoeneWolke closed 1 year ago

DieSchoeneWolke commented 1 year ago

Hey and thank you! Is it possible to attach the script to a running pi hole docker container so I don't have to rebuild?

jacklul commented 1 year ago

I don't think you can do this without actually installing the script inside the container. I'm not a Docker expert though and I might be wrong.

This could work: Set GRAVITY_DB config variable to point to the gravity.db file (that is stored in /etc/pihole mount, check your docker-compose.yml file), run the script then restart FTL within the container docker exec -it pihole "pihole restartdns".

DieSchoeneWolke commented 1 year ago

Thanks that did it!

Have a great weekend and happy holidays soon!

jacklul commented 1 year ago

Just remember that scheduled run won't be able to execute the last command so I suggest checking out this.

DieSchoeneWolke commented 1 year ago

oof. Sorry for being too lazy but honestly as a relatively new user I can't study every repo when I have a hard time understanding most of it, especially since I'm trying to run a pi-hole on my openmediavault server for like 2 months. 😭 I ran the script at the default values beside the edited gravity.db path from my docker volume. I then edited the /etc/pihole-updatelists.conf and included the recommended firebog and whitelist file. Should this suffice with the last hint you gave me?

jacklul commented 1 year ago

No, it won't reload DNS server after weekly scheduled lists update. (technically Pi-hole's image should do internal lists update a day after my default schedule) As mentioned in my previous message you have to edit one thing:

sudo systemctl edit pihole-updatelists.service
[Service]
Type=oneshot
ExecStartPost=docker exec -it pihole "pihole restartdns"

This should do it but I cannot guarantee it.

You might also need to add UPDATE_GRAVITY=null to the config to prevent some errors popping out in the output.

DieSchoeneWolke commented 1 year ago

sudo systemctl edit pihole-updatelists.service doesn't work because systemctl isn't installed in my container.

jacklul commented 1 year ago

You should execute those on the host machine, where you installed my script.

DieSchoeneWolke commented 1 year ago

Ah now it broke the ice I hope. So I started from scratch now with this repo. I think I completely misunderstood the point of this. So basically what I only needed to do is to run the script on my host, then use your docker image instead of the official one, configure this as explained in the docker section with the additional volume and then just configure the /etc/pihole-updatelists.conf file on my host machine, right?

jacklul commented 1 year ago

If you want to use the image from this repo you shouldn't install the script in the host machine at all - just follow the readme. The script will run inside the container if you use jacklul/pihole image, the steps I wrote earlier are for the cases where you don't want to use anything than official pihole/pihole image but still use this script.