2021-04-13 17:26:11 +02:00
|
|
|
set -eu
|
2021-04-13 18:25:28 +02:00
|
|
|
|
2021-04-18 22:41:35 +02:00
|
|
|
indb="$1"
|
|
|
|
outdir="$2"
|
2021-04-18 18:10:25 +02:00
|
|
|
|
2021-04-27 15:48:20 +02:00
|
|
|
# for chunked mode, we need to know the database size in bytes beforehand
|
2021-04-18 22:41:35 +02:00
|
|
|
bytes="$(stat --printf="%s" "$indb")"
|
2021-04-27 15:48:20 +02:00
|
|
|
# set chunk size to 10MiB (needs to be a multiple of the `pragma page_size`!)
|
|
|
|
serverChunkSize=$((10 * 1024 * 1024))
|
2021-04-13 17:26:11 +02:00
|
|
|
suffixLength=3
|
2021-04-18 22:41:35 +02:00
|
|
|
rm -f "$outdir/db.sqlite3"*
|
|
|
|
split "$indb" --bytes=$serverChunkSize "$outdir/db.sqlite3." --suffix-length=$suffixLength --numeric-suffixes
|
2021-04-27 15:48:20 +02:00
|
|
|
|
|
|
|
# set request chunk size to match page size
|
2021-04-18 22:41:35 +02:00
|
|
|
requestChunkSize="$(sqlite3 "$indb" 'pragma page_size')"
|
2021-04-27 15:48:20 +02:00
|
|
|
|
|
|
|
# write a json config
|
2021-04-13 18:25:28 +02:00
|
|
|
echo '
|
|
|
|
{
|
2021-04-27 15:48:20 +02:00
|
|
|
"serverMode": "chunked",
|
2021-04-18 18:10:25 +02:00
|
|
|
"requestChunkSize": '$requestChunkSize',
|
2021-04-13 18:25:28 +02:00
|
|
|
"databaseLengthBytes": '$bytes',
|
|
|
|
"serverChunkSize": '$serverChunkSize',
|
|
|
|
"urlPrefix": "db.sqlite3.",
|
|
|
|
"suffixLength": '$suffixLength'
|
|
|
|
}
|
2021-04-27 15:48:20 +02:00
|
|
|
' > "$outdir/config.json"
|