#!/bin/bash
mode="dev"


if [[ $* =~ ^(prod)$ ]]; then 
	mode="prod"
fi

if [ $mode == "dev" ]; then
    echo "[Installing AURA ENGINE for Development]"
fi
if [ $mode == "prod" ]; then
    echo "[Installing AURA ENGINE for Production]"
fi


# Development and Production

echo "Installation OPAM Packages ..."
bash script/install-opam-packages.sh

echo "Installing Web Application Packages ..."
bash script/install-web.sh

echo "Installing Python Requirements ..."
python3.7 $(which pip3) install -r requirements.txt


# Development 

if [ $mode == "dev" ]; then

    echo "Create local 'logs' Folder ..."
    mkdir -p logs

    echo "Copy configuration to './configuration/engine.ini'"
    cp -n configuration/sample-development.engine.ini configuration/engine.ini
fi


# Production 

if [ $mode == "prod" ]; then

    echo "Create local 'tmp' Folder ..."
    mkdir -p tmp

    echo "Copy configuration to '/etc/aura/engine.ini'"
    cp -n configuration/sample-production.engine.ini /etc/aura/engine.ini
fi


echo 
echo "+++ Installation of AURA Engine finished! +++"
echo