Closed eejeel closed 4 years ago
thank you for reporting this. there was indeed a problem with backslashes, the problem is solved by replacing 'while read regex' by 'while read -r regex'
if you want to import entries, using special characters, you need to identify these characters, by preceding them with a backslash. Example:
sudo sqlite3 /etc/pihole/gravity.db "insert or ignore into domainlist (domain, type, enabled, comment) values (\"^mads\\.\", 3, 1, \"mmotti regex\");"
The script is only intended to import the mmotti regular expressions once, backup, delete and restore is not part of the goal the script wants to achieve (ref. the manual)
I've updated the script in the repository.
closed after 21 days
Hi
in your script a \ in a regex file is not stored in the database.
For example (from https://github.com/mmotti/pihole-regex/blob/master/miscellaneous/amp.list) ^(.+[.-])?amp(project)?. It becomes ^(.+[.-])?amp(project)?.
or from https://github.com/mmotti/pihole-regex/blob/master/social/facebook.list ^(.+[_.-])?(facebook|fb(cdn|sbx)?|tfbnw).[^.]+$
I discover this because I also use your script for storing a local regex file with f.i. (^|.) (cdn.dns[0-6].).*
I investigate some time but at the moment cannot find the reason. Cause is the do loop. A manual update works correct sudo sqlite3 /etc/pihole/gravity.db "insert or ignore into domainlist (domain, type, enabled, comment) values ('.in-addr.arpa$', 3, 1, 'test1');"
With this script you can see the output in a file that ^mads. becomes ^mads. No database access
Another point: I also have expand you script with a backup and delete before updating the database table. In this case removed regex lines are also removed in teh databease