jessedp / pihole5-list-tool

A tool for quickly and easily bulk adding allow and ad/block lists to a Pi-hole 5 installation
MIT License
312 stars 18 forks source link

SQLite error after attempting to add blocklists using $sudo pihole5-list-tool #5

Closed SprMario closed 4 years ago

SprMario commented 4 years ago

After the installs and a few restarts I just can't get around this error.

`Traceback (most recent call last): File "/usr/local/bin/pihole5-list-tool", line 10, in sys.exit(main())

File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 95, in main process_blacklists(db_file)

File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 140, in process_blacklists conn = sqlite3.connect(db_file)

sqlite3.OperationalError: unable to open database file ` At first I tried the /etc/pihole/gravity.db path just to see if it would work because my install is on a docker image, it didnt. So I tried to direct it to the path I have /etc/pihole bound to which is /srv/disk-by-label-MEDIASERVER/appdata/pihole. I run an OpenMediaVault(v5) server using docker images for my media and pihole.

Here is a screenshot as well: https://i.imgur.com/mmEdhyA.png

According to your install guide I am sure I have the correct versions of the necessary software. Pihole works just fine I just get that error trying to use your tool.

Thanks in advance!

jessedp commented 4 years ago

Did you run it using sudo / as root?

If you did and it failed, it very well could be related to the docker-based install. I'll have to look around to see the recommended approach. My guess, thought would be do this:

Obviously that's a few minutes without DNS. There's a faster and potentially destructive way to do that, but I don't know consequences it would have.

SprMario commented 4 years ago

Did you run it using sudo / as root?

If you did and it failed, it very well could be related to the docker-based install. I'll have to look around to see the recommended approach. My guess, thought would be do this:

  • stop docker (so it lets go of the file)
  • update pihole
  • start the docker image.

Obviously that's a few minutes without DNS. There's a faster and potentially destructive way to do that, but I don't know consequences it would have.

Yes, I did run it as root/sudo. I tried following your suggestions by trying to get it to work when the docker is not running but I get the same error. Is your tool based on an install that's done normally/manually?

jessedp commented 4 years ago

Correct, it was built and tested against a standard installation on, literally, a raspberry pi. Until just now, I've never tested against a docker installation. However, the tool still only needs permissions/ability to update the "gravity.db" file that the docker version uses.

I'm pretty docker illiterate, but I think what I just did was the most basic test (which also may not be valid) and updating the linked db file worked fine while the container was running.

- verify there's a /etc/pihole/
- copy the docker-compose.yml example
$ sudo docker pull pihole/pihole:latest
$ sudo docker-compose run pihole
$ sudo pihole5-list-tool

It didn't (can't) run the command to reload the db, but I'd expect that. I'll post back if I dig into it more.

SprMario commented 4 years ago

A docker install doesn't create a /etc/pihole because you'd bind that path tho something like /srv/dev-disk/folder/pihole(in my case) so the actual files are not in the right place for the script to load/make the db. Is this something you will implement for docker users?

jessedp commented 4 years ago

Are you still having a problem with the tool updating the db file?

I mentioned that path b/c the pihole docker image uses it in the example for the host OS (and I already had stuff there). The tool allows you to enter the path to your db file. Are you looking for an easier way to enter the path, like a cli argument or somehow detecting where you're db is?

I feel like I'm missing something.

SprMario commented 4 years ago

So I remade the docker and reinstalled the list tool. Now I think I have a permission conflict as it gives me this error

Traceback (most recent call last): File "/usr/local/bin/pihole5-list-tool", line 10, in <module>sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 95, in main process_blacklists(db_file) File "/usr/local/lib/python3.7/dist-packages/ph5lt.py", line 140, in process_blacklistsconn = sqlite3.connect(db_file) sqlite3.OperationalError: unable to open database file

I am signed in as root and using sudo for the command but I am still unable to add the lists.

jessedp commented 4 years ago

I never looked at your screen shot, and I believe I see the problem now. It looks like you are entering the directory the file is in and not the actual file. So you probably want something like:

/srv/dev-disk-by-label-MEDIASERVER/appdata/Pihole/galaxy.db

And aside from looking at everything people tell me, I'll also add some checks in to make sure we have something that might be the galaxy database.

Apologies for probably wasting two days of your time.