backend_lib.sh 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. . bash_library.sh # source bash_library.sh
  2. function install_backend_system_dep {
  3. log "install base debian-packaged-dep for backend..."
  4. sudo apt update
  5. sudo apt install -y python3 python3-venv python3-dev python3-pip
  6. sudo apt install -y redis-server
  7. log "install deps for dealing with most preview..."
  8. sudo apt install -y zlib1g-dev libjpeg-dev
  9. sudo apt install -y imagemagick libmagickwand-dev ghostscript
  10. sudo apt install -y libreoffice # most office documents file and text format
  11. sudo apt install -y inkscape # for .svg files.
  12. }
  13. function setup_pyenv {
  14. log "setup python3 env.."
  15. python3 -m venv env
  16. source env/bin/activate
  17. }
  18. function install_backend_python_packages {
  19. pip install --upgrade pip setuptools
  20. log "install tracim-backend (sqlite_backend)..."
  21. pip install -e ".[testing]"
  22. }
  23. function setup_config_file {
  24. log "configure tracim with default conf..."
  25. if [ ! -f development.ini ]; then
  26. log "generate missing development.ini ..."
  27. cp development.ini.sample development.ini
  28. fi
  29. if [ ! -f wsgidav.conf ]; then
  30. log "generate missing wsgidav.conf ..."
  31. cp wsgidav.conf.sample wsgidav.conf
  32. fi
  33. if [ ! -f ../color.json ]; then
  34. log "generate missing color.json ..."
  35. cp ../color.json.sample ../color.json
  36. fi
  37. }
  38. function setup_db {
  39. result=$(alembic -c development.ini current)
  40. if [ $? -eq 0 ] && [ ! "$result" == '' ]; then
  41. log "check database migration..."
  42. alembic -c development.ini upgrade head
  43. else
  44. log "database seems missing, init it..."
  45. tracimcli db init
  46. alembic -c development.ini stamp head
  47. fi
  48. }