#!/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" BAD_SQL_CONFIGURATION="-Migration cannot be applied to the database : check your database configuration, or use sqlite instead" # 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 # Create a virtual env for Python3 cd ../ mkdir -p private echo $PRIVATE_DIR_CREATE cd private/ # create a venv_py35_pyros/ folder inside PYROS/private/ echo $VENV_CREATE virtualenv $VENV_NAME -p $PYTHON_DIR # Activate the virtual env echo $VENV_ACTIVATE source ./venv_py35_pyros/bin/activate echo "Python version :" python -V # Upgrade pip echo $UPGRADE_PIP pip install --upgrade pip # Upgrade wheel echo $UPGRADE_WHEEL pip install --upgrade wheel # Install the needed python packages echo $INSTALL_PACKAGES pip install -r ../install/REQUIREMENTS.txt # Create the database and a superuser pyros cd ../src/ echo $CREATE_DATABASE python manage.py makemigrations python manage.py migrate if [ $? -ne 0 ]; then echo $BAD_SQL_CONFIGURATION exit fi echo $CREATE_SUPERUSER python manage.py createsuperuser echo $INSTALLATION_FINISHED