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.
 
 
 

33 lignes
783 B

  1. #!/bin/bash
  2. # Compresses the database in the current directory using the filename of the .json file for naming.
  3. if [[ ! -f wpull.db ]]; then
  4. printf 'Error: wpull.db does not exist.\n' >&2
  5. exit 1
  6. fi
  7. if lsof wpull.db >/dev/null; then
  8. printf 'Error: wpull.db is opened by another process.\n' >&2
  9. exit 1
  10. fi
  11. jsonfiles=(*.json)
  12. if [[ ${#jsonfiles[@]} -eq 0 ]]; then
  13. printf 'Error: no .json file\n' >&2
  14. exit 1
  15. elif [[ ${#jsonfiles[@]} -gt 1 ]]; then
  16. printf 'Error: two or more .json files\n' >&2
  17. exit 1
  18. fi
  19. outname="${jsonfiles[0]%.json}-wpull.db.zst"
  20. if [[ -e "${outname}" ]]; then
  21. printf 'Error: %q already exists\n' "${outname}" >&2
  22. exit 1
  23. fi
  24. printf 'WAL checkpoint...\n'
  25. sqlite3 wpull.db 'PRAGMA wal_checkpoint'
  26. printf 'Compressing...\n'
  27. zstd -10 -o "${outname}" wpull.db