Browse Source

update backend setup script

Guénaël Muller 6 years ago
parent
commit
33d3937476
2 changed files with 60 additions and 23 deletions
  1. 52 0
      backend_lib.sh
  2. 8 23
      setup_default_backend.sh

+ 52 - 0
backend_lib.sh View File

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

+ 8 - 23
setup_default_backend.sh View File

@@ -1,32 +1,17 @@
1
-#!/usr/bin/bash
1
+#!/bin/bash
2 2
 . bash_library.sh # source bash_library.sh
3
+. backend_lib.sh # source backend_lib.sh
3 4
 
4
-log "install base debian-packaged-dep for backend..."
5
-sudo apt update
6
-sudo apt install python3 python3-venv python3-dev python3-pip
7
-sudo apt install redis-server
8
-
9
-log "install deps for dealing with most preview..."
10
-sudo apt install zlib1g-dev libjpeg-dev
11
-sudo apt install imagemagick libmagickwand-dev ghostscript
12
-sudo apt install libreoffice # most office documents file and text format
13
-sudo apt install inkscape # for .svg files.
5
+install_backend_system_deb
14 6
 
15 7
 log "go to backend subdir.."
16 8
 cd backend || exit 1;
17 9
 
18
-log "setup python3 env.."
19
-python3 -m venv env
20
-source env/bin/activate
21
-pip install --upgrade pip setuptools
22
-
23
-log "install tracim-backend (sqlite_backend)..."
24
-pip install -e ".[testing]"
25
-
26 10
 
27
-log "configure tracim with default conf..."
28
-cp development.ini.sample development.ini
29
-cp wsgidav.conf.sample wsgidav.conf
30
-tracimcli db init
11
+install_backend_system_dep
12
+setup_pyenv
13
+install_backend_python_packages
14
+setup_config_file
15
+setup_db
31 16
 
32 17
 log "backend of tracim was correctly set-up."