1
0
mirror of https://github.com/phiresky/sql.js-httpvfs.git synced 2024-11-08 20:22:44 +01:00
sql.js-httpvfs/create_db.sh

20 lines
547 B
Bash
Raw Normal View History

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-18 22:41:35 +02:00
bytes="$(stat --printf="%s" "$indb")"
2021-04-13 17:26:11 +02:00
serverChunkSize=$((50 * 1024 * 1024))
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
requestChunkSize="$(sqlite3 "$indb" 'pragma page_size')"
2021-04-13 18:25:28 +02:00
echo '
{
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-18 22:41:35 +02:00
' > "$outdir/config.json"