Blame view

install/install_requirements.sh 2.07 KB
6101568a   haribo   Improved install_...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

PYTHON='python3.5'
INSTALL_DIR='install'
VENV_NAME="venv_py35_pyros"

# String variables

WRONG_DIRECTORY="-Wrong directory : please run this script from the '$INSTALL_DIR' directory"
PRIVATE_DIR_CREATE="-Created 'private' directory"
PYTHON_NOT_INSTALLED="-Cannot find $PYTHON, please install it or configure PYTHON variable in this script"
PYTHON_FOUND="-Found $PYTHON at"
VENV_CREATE="-Creating virtualenv $VENV_NAME... "
VENV_ACTIVATE="-Activating virtual environment... "
DONE="done."
UPGRADE_PIP="-Upgrading pip:"
UPGRADE_WHEEL="-Upgrading wheel:"
INSTALL_PACKAGES="-Installing required packages from install/REQUIREMENTS.txt"
CREATE_DATABASE="-Creating database tables :"
CREATE_SUPERUSER="-Creating database superuser :"
INSTALLATION_FINISHED="-Installation finished"
609eb83d   haribo   Improved install_...
22
BAD_SQL_CONFIGURATION="-Migration cannot be applied to the database : check your database configuration, or use sqlite instead"
6101568a   haribo   Improved install_...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

# Getting python location
PYTHON_DIR=`which $PYTHON`
if [ $? -ne 0 ]; then
    echo $PYTHON_NOT_INSTALLED
    exit
fi
echo $PYTHON_FOUND $PYTHON_DIR

# Getting current path to test if we are in the install directory
CURRENT_PATH=`pwd`
CURRENT_PATH=${CURRENT_PATH##*/}

if [ "$CURRENT_PATH" != $INSTALL_DIR ]; then
    echo $WRONG_DIRECTORY
    exit
fi
e56481aa   Etienne Pallier   new install script
40
41
42

# Create a virtual env for Python3
cd ../
6101568a   haribo   Improved install_...
43
44
45
46
47

mkdir -p private

echo $PRIVATE_DIR_CREATE

e56481aa   Etienne Pallier   new install script
48
cd private/
6101568a   haribo   Improved install_...
49

e56481aa   Etienne Pallier   new install script
50
# create a venv_py35_pyros/ folder inside PYROS/private/
6101568a   haribo   Improved install_...
51
52
echo $VENV_CREATE
virtualenv $VENV_NAME -p $PYTHON_DIR
e56481aa   Etienne Pallier   new install script
53
54

# Activate the virtual env
6101568a   haribo   Improved install_...
55
56
echo $VENV_ACTIVATE
source ./venv_py35_pyros/bin/activate
e56481aa   Etienne Pallier   new install script
57

6101568a   haribo   Improved install_...
58
59
echo "Python version :"
python -V
3253ad8e   Etienne Pallier   new script for in...
60
61

# Upgrade pip
6101568a   haribo   Improved install_...
62
echo $UPGRADE_PIP
3253ad8e   Etienne Pallier   new script for in...
63
pip install --upgrade pip
6101568a   haribo   Improved install_...
64

3253ad8e   Etienne Pallier   new script for in...
65
# Upgrade wheel
6101568a   haribo   Improved install_...
66
echo $UPGRADE_WHEEL
3253ad8e   Etienne Pallier   new script for in...
67
68
69
pip install --upgrade wheel

# Install the needed python packages
6101568a   haribo   Improved install_...
70
echo $INSTALL_PACKAGES
e56481aa   Etienne Pallier   new install script
71
72
pip install -r ../install/REQUIREMENTS.txt

4c270b9e   Etienne Pallier   updated install s...
73
# Create the database and a superuser pyros
e56481aa   Etienne Pallier   new install script
74
cd ../src/
6101568a   haribo   Improved install_...
75
76
77
78
echo $CREATE_DATABASE
python manage.py makemigrations
python manage.py migrate

609eb83d   haribo   Improved install_...
79
80
81
82
83
if [ $? -ne 0 ]; then
    echo $BAD_SQL_CONFIGURATION
    exit
fi

6101568a   haribo   Improved install_...
84
85
echo $CREATE_SUPERUSER
python manage.py createsuperuser
e56481aa   Etienne Pallier   new install script
86

6101568a   haribo   Improved install_...
87
echo $INSTALLATION_FINISHED