Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if skipgravityonboot set, check db version. #1402

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

edgd1er
Copy link
Contributor

@edgd1er edgd1er commented Jul 26, 2023

during pihole -g version is checked and db updated if needed.

Description

At boot time either run pihole -g or check and upgrade database structure if needed.

Motivation and Context

Updating everyday or at every start lists may be of little use and harsh on lists servers.
Allowing to bypass update at boot time, speed up the start and avoid traffic on lists servers.
Some lists are on github servers, too many accesses may trigger ban rules.

Fix #1398

When SKIPGRAVITYONBOOT is not set (default), pihole -g runs at boot time.
it checks database's version and upgrade it if needed.

SKIPGRAVITYONBOOT allows to bypass the "pihole -g" step, hence database version is not checked anymore, lists are not updated.
Depending on the last update, incorrect version will cause many errors in the admin website.

How Has This Been Tested?

I copied v5 databases to v6 container's volumes, an checked that database structure was updated and lists were not.

docker-pi-hole-pihole-1  | + gravityDBfile=/etc/pihole/gravity.db
docker-pi-hole-pihole-1  | + '[' -n true ']'
docker-pi-hole-pihole-1  | + '[' -f /etc/pihole/gravity.db 
docker-pi-hole-pihole-1  | ']'
docker-pi-hole-pihole-1  |   Skipping Gravity Database Update.
docker-pi-hole-pihole-1  | + echo '  Skipping Gravity Database Update.'
docker-pi-hole-pihole-1  | + source /opt/pihole/utils.sh
docker-pi-hole-pihole-1  | + source /etc/.pihole/advanced/Scripts/database_migration/gravity-db.sh
docker-pi-hole-pihole-1  | ++ readonly scriptPath=/etc/.pihole/advanced/Scripts/database_migration/gravity
docker-pi-hole-pihole-1  | ++ scriptPath=/etc/.pihole/advanced/Scripts/database_migration/gravity
docker-pi-hole-pihole-1  | + upgrade_gravityDB /etc/pihole/gravity.db /etc/pihole
docker-pi-hole-pihole-1  | + local database 
docker-pi-hole-pihole-1  | piholeDir 
docker-pi-hole-pihole-1  | auditFile version
docker-pi-hole-pihole-1  | + database=/etc/pihole/gravity.db
docker-pi-hole-pihole-1  | + 
docker-pi-hole-pihole-1  | piholeDir=/etc/pihole
docker-pi-hole-pihole-1  | + auditFile=/etc/pihole/auditlog.list
docker-pi-hole-pihole-1  | ++ pihole-FTL sqlite3 /etc/pihole/gravity.db 'SELECT "value" FROM "info" WHERE "property" = '\''version'\'';'
docker-pi-hole-pihole-1  | + version=16
docker-pi-hole-pihole-1  | + [[ 16 == \1 ]]
docker-pi-hole-pihole-1  | + [[ 16
docker-pi-hole-pihole-1  |  == 
docker-pi-hole-pihole-1  | \2 ]]
docker-pi-hole-pihole-1  | + [[ 
docker-pi-hole-pihole-1  | 16 == \3 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \4 ]]
docker-pi-hole-pihole-1  | + 
docker-pi-hole-pihole-1  | [[ 16
docker-pi-hole-pihole-1  |  == 
docker-pi-hole-pihole-1  | \5 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \6 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \7 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \8 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \9 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \1\0 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \1\1 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \1\2 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \1\3 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \1\4 ]]
docker-pi-hole-pihole-1  | + [[ 16 == \1\5 ]]

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@PromoFaux
Copy link
Member

Thanks, I'll take a look at this later on. In the meantime, could you rebase on development-v6 and maybe look at adding some tests for this section of code? Not sure about testing the db upgrade part, but the other parts should be testable

@PromoFaux
Copy link
Member

@edgd1er , looks like you rebased on the wrong branch :)

@PromoFaux
Copy link
Member

I have now merged the UID/GID branch in, so please rebase on development-v6 once more (I can do this for you if you need help!)

@edgd1er edgd1er force-pushed the skigravityonboot branch 2 times, most recently from 5a4f8f8 to e497cb9 Compare July 26, 2023 16:42
@edgd1er
Copy link
Contributor Author

edgd1er commented Jul 26, 2023

I have now merged the UID/GID branch in, so please rebase on development-v6 once more (I can do this for you if you need help!)

I've rebased and signed off. it should be ok, now

src/start.sh Outdated Show resolved Hide resolved
src/start.sh Show resolved Hide resolved
Signed-off-by: Adam Warner <[email protected]>
@PromoFaux PromoFaux merged commit fa2eb0d into pi-hole:development-v6 Aug 9, 2023
4 of 5 checks passed
@sonarcloud
Copy link

sonarcloud bot commented Aug 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@edgd1er edgd1er deleted the skigravityonboot branch November 8, 2023 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants