[Magisk] 73sydney:
Automatically optimizes SQLite databases on boot, on schedule, every X days.

Just a quick and dirty adaptation of an old SQLite3 optimizer script from init.d days to a Magisk Module using a service.sh script instead, with an internal date offset mechanism to run the script every X days (default: 3 - which is plenty, and specifically to stop silliness).

Update And credit note: finally after a fair bit of digging, i think i located the original author of the original init.d version of the main vacuum code snippet ive repurposed (stolen) for this module. It appears to be from user @mcbyte_it (doesnt seem to be current or active) and from a post here. Although i only saw derivative reworkings of this script, and used only the main sqllite script function, i arrived at a different method of tracking last run date, when his is arguably more mainstream/concise. Im fairly certain this is the originator especially as the post also has a zipalign script that was also suggested to me to do....and which i have been fiddling with for months....

The script will wait until boot is completed AND then until avg CPU usage is under 30%, to minimise the risk of possible corruption.

Disclaimer: As always any use of any 3rd party script/software/advice is at the users discretion. All reasonable efforts have been made to make this as safe as possible, but the responsibility ultimately falls to the user whether to use and run the script.

What it does:​

It:

Reindexes

Vacuums

Analyzes

all .db files under /data.

It runs a 1st run optimize after install (temp file optimsql_first_run on sdcard is used to enable this, and removed after first run), and then on schedule after that.

By default it logs just script progress to /storage/emulated/0/autosqlite.log, but you can choose to enable more detail in the log if you wish

​

User Configurable Options:​

The schedule and loglevel can be changed by an external file on sdcard:

Create a file named autosqlite_options on sdcard (/storage/emulated/0/)

Inside create the follow key=value pairs to suit your preference:

interval=x (where x is the number of days between script runs, for the love of god do not put 1 (this goes out especially to the kind of people who put every app on their Magisk magiskhide/deny list) there is no benefit and you just heighten the possibility of corruption)

loglevel=x (where x is either 1 (detailed logging) or 0 (basic logging - default))

Requirements:​

This module requires a working SQLite3 binary. If your ROM does not provide one (you can check via typing sqlite3 into a terminal), you can choose to use my SQLite3UniversalBinaries module located here:

https://github.com/stylemessiah/SQLite3UniversalBinaries

Dont forget you need to download a named SQLite3UniversalBinaries.vx.x.zip file from the Releases page under Assets. Do not try installing the source code with Magisk Manager, it will not go as you expect

All the modules action takes place in the service.sh file, its commented reasonably well for those wanting to check how it works

* See... now theres something else to use with my SQLite3 Universal Binaries module other than the GPay SQlite Fix Module <- dont use that anymore, it makes me stabby. It is literally the last resort for getting Google Pay/Wallet to work ,

Please note: the included LICENSE only covers the module components provided by the excellent work of @Zackptg5 's Magisk Module Extended, which is available for here for module creators

https://github.com/Zackptg5/MMT-Extended/

All other work is credited above and no one may fork or re-present this module as their own for the purposes of trying to monetize this module or its content without all parties permission. The module comes specifically without an overall license for this intent.

Download:

Repo: https://github.com/stylemessiah/AutomaticSQLiteDBOptimizer

Release: https://github.com/stylemessiah/AutomaticSQLiteDBOptimizer/releases/latest

Powered by Ponkle