Hey lovers of a ad-free web,
I am a very fan of pi-hole. I am trying to write something like a group-policy for some pihole v5 instances. I am doing this because I am that much a fan, that I want to have one pihole in every household of family members (grandparent, aunts and uncles, parents ..) I wite a bash script for a debian based installation. My goal is to manage (adding blocklists, white- and blacklisting etc) some instances from a central point. My script works, but I can´t add blocklists/ and do white/blacklisting via script.
if [ "$ScriptVersion" -eq '1' ]; then
sqlite3 .open /etc/pihole/gravity.db #it´s failing here because "Error near '/' syntax error" I´ve also tried to put the path in a variable $DatabasePath but didn´t helped.
Versions I tried, while being signed in a root:
- sqlite3 .open /etc/pihole/gravity.db
- sqlite3
.open /etc/pihole/gravity.db - sqlite3
sqlite .open /etc/pihole/gravity.db - sqlite3 /etc/pihole/gravity.db <<MY_QUERY
INSERT INTO adlist (address, enabled, comment) VALUES ("https://domain.com/blocklist.txt", 1, "ANTI Tracking");
MY_QUERY
also Tried to put the path in $DatabasePath but still without success.
If I am doing it manually, it just works fine
sqlite3
.open /etc/pihole/gravity.db
INSERT INTO adlist (address, enabled, comment) VALUES ("https://domain.com/blocklist.txt", 1, "ANTI Tracking");
elif [ "$ScriptVersion" -eq '2' ]; then
#add a new blocklist
...
...
else
echo "You´re done BYE!!! "
Can please someone help me how I can manage my Pi-Hole via bash-script?