Editing a domain's group assignment via script?

Is it possible to edit a domain's group assignment via a script/on the command line?

I've looked through the man page for pihole, and it does not mention groups anywhere. I see that editing a domain's group assignment via the admin UI uses this section of groups.php, but I'm not sure if that gets me any closer.

I also looked through the source of /usr/local/bin/pihole and found no mention of the word group.

The output of pihole -v is as follows:

Pi-hole version is v5.0 (Latest: v5.0)
AdminLTE version is v5.0 (Latest: v5.0)
FTL version is v5.0 (Latest: v5.0)

My use case, if the context helps: I'd like to (at least attempt to) use my pi-hole for parental controls. I was going to set up a separate pi-hole instance/device for this purpose, but with the release of 5.0 and group management, it seems like this should be very doable on one pi-hole. I can of course do this via the GUI, but I'm interested in building some tools to more easily/quickly whitelist and blacklist domains for a particular group.

Thanks for any guidance or suggestions you can provide!

For what it's worth, I'm certainly open to "this doesn't exist yet, but here's a rough outline of how you could add it to the pihole script" – I'd love to submit a PR to add this, given, a little guidance.

Yes it is possible. See here for the documentation providing sqlite3 examples you can use at the CLI
https://docs.pi-hole.net/database/gravity/example/

Domain - Group associations are stored in the table "domainlist_by_group"

Here is a sample to change the group_id from zero ("Default") to one (some group you created) for an domain with the domain_id=3

sqlite3 /etc/gravity.db "update domainlist_by_group set group_id=1 where domainlist_id=3;"

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.