backend_lib.sh 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }
  34. function setup_db {
  35. result=$(alembic -c development.ini current)
  36. if [ $? -eq 0 ] && [ ! "$result" == '' ]; then
  37. log "check database migration..."
  38. alembic -c development.ini upgrade head
  39. else
  40. log "database seems missing, init it..."
  41. tracimcli db init
  42. alembic -c development.ini stamp head
  43. fi
  44. }