The little things give you away... A collection of various small helper stuff
Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- #!/bin/bash
- # Compresses the database in the current directory using the filename of the .json file for naming.
- if [[ ! -f wpull.db ]]; then
- printf 'Error: wpull.db does not exist.\n' >&2
- exit 1
- fi
-
- if lsof wpull.db >/dev/null; then
- printf 'Error: wpull.db is opened by another process.\n' >&2
- exit 1
- fi
-
- jsonfiles=(*.json)
- if [[ ${#jsonfiles[@]} -eq 0 ]]; then
- printf 'Error: no .json file\n' >&2
- exit 1
- elif [[ ${#jsonfiles[@]} -gt 1 ]]; then
- printf 'Error: two or more .json files\n' >&2
- exit 1
- fi
-
- outname="${jsonfiles[0]%.json}-wpull.db.zst"
- if [[ -e "${outname}" ]]; then
- printf 'Error: %q already exists\n' "${outname}" >&2
- exit 1
- fi
-
- printf 'WAL checkpoint...\n'
- sqlite3 wpull.db 'PRAGMA wal_checkpoint'
-
- printf 'Compressing...\n'
- zstd -10 -o "${outname}" wpull.db
|