Hi,
I can run command to add RegEx in my Pi-Hole (Raspberry Pi ZERO W), however I'm using groups to distinguish my devices.
It seems that it's not possible to add specific domain to the black list and setup group assigment on it.
So I was trying find a way to update existing entry in the domain list with specific group assigment.
See this topic, as there was a similar question. You need to adjust the sql commands to your needs, but it should give you a feeling how to accomplish what you want
I was not aware it's so easy. One is more than enough,
I will just assign domains to another group ( group_id=1 ) and update status (enable or disable) for all of them.
enabled => 0 = disabled, 1 = enabled)
sudo sqlite3 /etc/pihole/gravity.db "Update domainlist SET enabled = 0 WHERE id in (Select domainlist_id from domainlist_by_group where group_id=1);"
Just for sharing.. finally I'v intergrated pihole with my Home Assistant.
Now I'm able to disable and enable all fun domeins in specific group, with one click, or Home Assistant automation. This takes away one more distraction from my kid during remote clases. Kind of parental control
Due to my Adlist, some domains has to be on white list, therfore final version of script in addition is enabling whtelist, when blacklist is turned off (and the other way around).
#Black List ON
sudo sqlite3 /etc/pihole/gravity.db "UPDATE domainlist SET enabled = 1 WHERE type IN (1,3) AND id IN (SELECT domainlist_id FROM domainlist_by_group WHERE group_id=1);" && sudo sqlite3 /etc/pihole/gravity.db "UPDATE domainlist SET enabled = 0 WHERE type IN (2,4) AND id IN (SELECT domainlist_id FROM domainlist_by_group WHERE group_id=1);"
#Black List OFF
sudo sqlite3 /etc/pihole/gravity.db "UPDATE domainlist SET enabled = 0 WHERE type IN (1,3) AND id IN (SELECT domainlist_id FROM domainlist_by_group WHERE group_id=1);" && sudo sqlite3 /etc/pihole/gravity.db "UPDATE domainlist SET enabled = 1 WHERE type IN (2,4) AND id IN (SELECT domainlist_id FROM domainlist_by_group WHERE group_id=1);"
#For HA swich state:
sudo sqlite3 /etc/pihole/gravity.db "SELECT enabled FROM domainlist WHERE type IN (1,3) AND id in (Select domainlist_id from domainlist_by_group where group_id=1) LIMIT 1;"
I didn't tried to achieve similar on Group level, as I would probably need separate groups for Black and White list.
restartdns Full restart Pi-hole subsystems
Add 'reload' to update the lists and flush the cache without restarting the DNS server
Add 'reload-lists' to only update the lists WITHOUT flushing the cache or restarting the DNS server
So, to make Pi-hole aware of the changes pihole restartdns reload-lists is sufficient (and much faster than a full restart). This is also what happens if you change the status via web interface.