Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save allanaguilar/2c9541d19f0f4c86d0230e3bdc74944e to your computer and use it in GitHub Desktop.
Save allanaguilar/2c9541d19f0f4c86d0230e3bdc74944e to your computer and use it in GitHub Desktop.
Install flectra in a virtual env
Copyright (C) 2018  Robert Rottermann redO2oo.ch

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

Install flectra

This documentation is a work in progress.
It derives from documentation and scripts I did to create my own odoo environment.
Some of it comes from instructions that where posted on flectras gitter chat.
If you have questions, you can reach me on: robert@redo2oo.ch

----------- prepare the environment -----------

postgres must be up and running

sudo apt-get install postgresql postgresql-contrib

Install libraries

the following modules must be installed (as user root): The libraries mentioned here are the ones I use and must probably be adapted.
Be especially careful what postgresql-client-XX you need (2018 Jan 10.0 is actual)

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get -y install build-essential libfreetype6-dev libjpeg8-dev liblcms2-dev libldap2-dev  libsasl2-dev libssl-dev libffi-dev \
libtiff5-dev libwebp-dev libxml2-dev libxslt1-dev node-less postgresql-server-dev* python-dev python3-dev \
python-tk tcl8.6-dev tk8.6-dev zlib1g-dev postgresql-client-9.5 python-virtualenv git vim npm nodejs-legacy libmysqlclient-dev \
curl python3-dev python3-pip python3-setuptools npm nodejs git gdebi libldap2-dev libsasl2-dev  libxml2-dev libxslt1-dev libjpeg-dev

Install wkhtmltopdf, less & co

sudo npm install -g less less-plugin-clean-css -y && sudo ln -s /usr/bin/nodejs /usr/bin/node
cd /tmp

sudo wget https://downloads.wkhtmltopdf.org/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo gdebi -n wkhtmltox-0.12.2.1_linux-trusty-amd64.deb && sudo rm wkhtmltox-0.12.2.1_linux-trusty-amd64.deb -y

add wkhtmltopdf & co to the execute path

sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin/ && sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin/

install geo database

wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz \
&& sudo gunzip GeoLiteCity.dat.gz && sudo mkdir /usr/share/GeoIP/ -p \
&& sudo mv GeoLiteCity.dat /usr/share/GeoIP/

install virtual env

sudo apt install python3-venv python-pip  
sudo pip install virtualenvwrapper

add environment variables for the virtual environments

echo "# ------------------ start workon stuff -------------------" >> ~/.bashrc
echo export WORKON_HOME=$HOME/.virtualenvs >> ~/.bashrc
echo export PROJECT_HOME=$HOME/Devel >> ~/.bashrc
echo source /usr/local/bin/virtualenvwrapper.sh >> ~/.bashrc
echo "# ------------------ end workon stuff -------------------" >> ~/.bashrc
# restart the bash shell, only needed when installing
source ~/.bashrc

add yourself as postgres superuser to the database:

sudo -u postgres psql -e --command "CREATE USER $USER WITH SUPERUSER PASSWORD 'admin'"

----------- end preparation of the environment ------------

----------- do the flectra installation -----------

get flectra sources:

git clone https://gitlab.com/flectra-hq/flectra  

create a virtual envvironment where you want to run your flectra

cd flectra/

PROJECT_HOME=~/flectra mkvirtualenv -p python3 flectra

from now on, if you want to work with flectra, you first execute

workon flectra

to stop working in a virtualenv, you just execute

deactivate

install flectra

after having prepared the environment, we now can install flectra

workon flectra
cd ~/flectra
python setup.py install

This will take a few moments.
When it is done, you can start flectra:

./flectra-bin

----------- end flectra installation -----------

----------- create sensible environment -----------

You want to start every flectra setup with its own distinct
config file. This you should create and setup as next step.

We will create two directories and let flectra create a config file,
which we then will adapt.
The two new directories will be used to store the sessiondata
and our own modules

workon flectra
cd ~/flectra
# create a folder where session data is stored
md localdata
# create folder for our addons
mkdir custom_addons
./flectra-bin -c flectra.conf --save --stop-after-init

This produces a a config file: flectra.conf
This file we will adapt to be similar as the following sample.
Please adapt the following values:

  • change all /home/robert/flectra to /home/YOURHOME/YOURVIRTUALENV
  • change all roberts_flectra to a database name of your choice

all settings starting with a # sign are commented out and are set to their default

[options]
addons_path = /home/robert/flectra/flectra/addons,/home/robert/flectra/addons,/home/robert/flectra/custom_addons
admin_passwd = admin
session_dir = /home/robert/flectra/localdata
data_dir = /home/robert/flectra/localdata
dbfilter = roberts_flectra
http_port = 7073
db_name = roberts_flectra
db_password = admin
db_user = robert
demo = {}
max_cron_threads=0
#longpolling_port = 7072
#csv_internal_sep = ,
#db_host = False
#db_maxconn = 64
#db_name = False
#db_password = False
#db_port = False
#db_sslmode = prefer
#db_template = template1
#email_from = False
#geoip_database = /usr/share/GeoIP/GeoLiteCity.dat
#http_enable = True
#http_interface =
#import_partial =
#limit_memory_hard = 2684354560
#limit_memory_soft = 2147483648
#limit_request = 8192
#limit_time_cpu = 60
#limit_time_real = 120
#limit_time_real_cron = -1
#list_db = True
#log_db = False
#log_db_level = warning
#log_handler = :INFO
#log_level = info
#logfile = None
#logrotate = False
#osv_memory_age_limit = 1.0
#osv_memory_count_limit = False
#pg_path = None
#pidfile = None
#proxy_mode = False
#reportgz = False
#server_wide_modules = web
#smtp_password = False
#smtp_port = 25
#smtp_server = localhost
#smtp_ssl = False
#smtp_user = False
#syslog = False
#test_commit = False
#test_enable = False
#test_file = False
#test_report_directory = False
#translate_modules = ['all']
#unaccent = False
#without_demo = False
#workers = 0

You can start flectra with this new config file like so:

workon flectra
cd ~/flectra
./flectra-bin -c flectra.conf

------- if anything did not workout as it should

just delete the database.
Assuming the above names where used, execute:

dropdb roberts_flectra

----------- end create sensible environment -----------

----------- create your first addon -----------

The config file we just created, defines an custom addon-path,
where we can add our own addons.
With the following commands we will just do that.
Again change /home/robert/flectra/ to /home/YOURHOME/YOURVIRTUALENV

workon flectra
cd ~/flectra
./flectra-bin scaffold my_supper_dupper_addon /home/robert/flectra/custom_addons

This creates a skeleton addon in the custom_addons folder.
This addon can you adapt and load into your site.

----------- end create your first addon -----------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment