Skip to content

Commit

Permalink
Merge pull request #141 from PnEcrins/develop
Browse files Browse the repository at this point in the history
Merge Develop to Master
  • Loading branch information
camillemonchicourt committed Mar 15, 2018
2 parents 0f03516 + ffbbc93 commit da66ca2
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 29 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.3.1.dev0
9 changes: 9 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
CHANGELOG
=========

1.3.1 (2018-03-15)
------------------

**Corrections**

* Correction de l'installation autonome (sans GeoNature)
* Correction et documentation si l'atlas est accessible dans un sous-répertoire du domaine
* Correction d'une coquille dans le SQL. Merci @lpofredc

1.3.0 (2018-02-15)
------------------

Expand Down
20 changes: 12 additions & 8 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Ce serveur doit aussi disposer de :
GeoNature-atlas est susceptible de fonctionner sur d'autres OS (comme Ubuntu par exemple) mais cela n'a pas été testé.


Installation de l'environnement et de l'application
===================================================
Installation de l'environnement logiciel
========================================

Le script ``install_env.sh`` va automatiquement installer les outils nécessaires à l'application si ils ne sont pas déjà sur le serveur :

Expand Down Expand Up @@ -88,11 +88,6 @@ Cela installera les logiciels nécessaires au fonctionnement de l'application
cd /home/monuser/atlas
./install_env.sh

**4. Lancez l'installation automatique de l'application :**

::

./install_app.sh


Installation de la base de données
Expand Down Expand Up @@ -151,12 +146,21 @@ Si vous voulez adapter le contenu des vues matérialisées, vous pouvez modifier
Si vous souhaitez uniquement recréer la vue ``atlas.vm_observations`` et les 6 autres vues qui en dépendent vous pouvez utiliser le script ``data/update_vm_observations.sql``.


Installtion de l'application
============================

**Lancez l'installation automatique de l'application :**

::

./install_app.sh

Configuration de l'application
==============================

Editer le fichier de configuration ``main/configuration/config.py``.

- Renseignez la variable 'database_connection'
- Vérifier que la variable 'database_connection' contient les bonnes informations de connexion à la base
- Renseignez l'URL de l'application à partir de la racine du serveur WEB ('/atlas' ou '' par exemple)
- Renseignez les autres paramètres selon votre contexte
- Rechargez le serveur Web Gunicorn pour que les modifications soient prises en compte (``sudo supervisorctl reload``)
Expand Down
33 changes: 32 additions & 1 deletion initAtlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy

from werkzeug.wsgi import DispatcherMiddleware, ProxyMiddleware
from werkzeug.serving import run_simple

from main.configuration import config
from sqlalchemy import create_engine, MetaData, Table

Expand All @@ -13,10 +16,33 @@

APP_DIR = os.path.abspath(os.path.dirname(__file__))

class ReverseProxied(object):

def __init__(self, app, script_name=None, scheme=None, server=None):
self.app = app
self.script_name = script_name
self.scheme = scheme
self.server = server

def __call__(self, environ, start_response):
script_name = environ.get('HTTP_X_SCRIPT_NAME', '') or self.script_name
if script_name:
environ['SCRIPT_NAME'] = script_name
path_info = environ['PATH_INFO']
if path_info.startswith(script_name):
environ['PATH_INFO'] = path_info[len(script_name):]
scheme = environ.get('HTTP_X_SCHEME', '') or self.scheme
if scheme:
environ['wsgi.url_scheme'] = scheme
server = environ.get('HTTP_X_FORWARDED_SERVER', '') or self.server
if server:
environ['HTTP_HOST'] = server
return self.app(environ, start_response)

def create_app():
# renvoie une instance de app l appli Flask
app = Flask(__name__, template_folder=APP_DIR)

app.debug = config.modeDebug

from main.atlasRoutes import main as main_blueprint
Expand All @@ -28,11 +54,16 @@ def create_app():

compress.init_app(app)

app.wsgi_app = ReverseProxied(app.wsgi_app, script_name=config.URL_APPLICATION)


return app


app = create_app()


if __name__ == '__main__':
from flask_script import Manager
Manager(app).run()
# Manager(app).run()
run_simple('localhost', 8080, app, use_reloader=True)
13 changes: 9 additions & 4 deletions install_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ virtualenv $venv_dir
echo "Installing requirements..."
pip install -r requirements.txt

echo "Creating configuration files if they dont already exist"
if [ ! -f ./main/configuration/config.py ]; then
cp ./main/configuration/config.py.sample ./main/configuration/config.py
fi

sudo sed -i "s/database_connection = .*$/database_connection = \"postgresql:\/\/$user_pg:$user_pg_pass@$db_host:$db_port\/$db_name\"/" ./main/configuration/config.py


echo "Launching application..."
DIR=$(readlink -e "${0%/*}")
sudo -s cp atlas-service.conf /etc/supervisor/conf.d/
Expand All @@ -35,10 +43,7 @@ if [ ! -d ./static/custom/images/ ]; then
mkdir -p ./static/custom/images/
fi

echo "Creating configuration files if they dont already exist"
if [ ! -f ./main/configuration/config.py ]; then
cp ./main/configuration/config.py.sample ./main/configuration/config.py
fi


echo "Creating customisation files if they dont already exist"
if [ ! -f ./static/custom/templates/footer.html ]; then
Expand Down
47 changes: 32 additions & 15 deletions install_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ then
echo "Création de la table exemple syntheseff"
sudo -n -u postgres -s psql -d $db_name -c "CREATE TABLE synthese.syntheseff
(
id_synthese serial NOT NULL,
id_synthese serial PRIMARY KEY,
id_organisme integer DEFAULT 2,
cd_nom integer,
insee character(5),
Expand All @@ -115,14 +115,15 @@ then
altitude_retenue integer,
supprime boolean DEFAULT false,
the_geom_point geometry('POINT',3857),
effectif_total integer
effectif_total integer,
diffusable boolean
);
INSERT INTO synthese.syntheseff
(cd_nom, insee, observateurs, altitude_retenue, the_geom_point, effectif_total)
VALUES (67111, 05122, 'Mon observateur', 1254, '0101000020110F0000B19F3DEA8636264124CB9EB2D66A5541', 3);
(cd_nom, insee, observateurs, altitude_retenue, the_geom_point, effectif_total, diffusable)
VALUES (67111, 05122, 'Mon observateur', 1254, '0101000020110F0000B19F3DEA8636264124CB9EB2D66A5541', 3, true);
INSERT INTO synthese.syntheseff
(cd_nom, insee, observateurs, altitude_retenue, the_geom_point, effectif_total)
VALUES (67111, 05122, 'Mon observateur 3', 940, '0101000020110F00001F548906D05E25413391E5EE2B795541', 2);" &>> log/install_db.log
(cd_nom, insee, observateurs, altitude_retenue, the_geom_point, effectif_total, diffusable)
VALUES (67111, 05122, 'Mon observateur 3', 940, '0101000020110F00001F548906D05E25413391E5EE2B795541', 2, true);" &>> log/install_db.log
sudo -n -u postgres -s psql -d $db_name -c "ALTER TABLE synthese.syntheseff OWNER TO "$owner_atlas";"
fi

Expand All @@ -133,22 +134,38 @@ then
cd data
mkdir taxonomie
cd taxonomie
wget https://raw.githubusercontent.com/PnX-SI/TaxHub/master/data/taxhubdb.sql
sudo -n -u postgres -s psql -d $db_name -f taxhubdb.sql &>> ../../log/install_db.log
wget https://raw.githubusercontent.com/PnX-SI/TaxHub/$taxhub_release/data/taxhubdb.sql
#sudo -n -u postgres -s psql -d $db_name -f taxhubdb.sql &>> ../../log/install_db.log
export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f taxhubdb.sql &>> ../../log/install_db.log

wget http://geonature.fr/data/inpn/taxonomie/TAXREF_INPN_v9.0.zip
unzip TAXREF_INPN_v9.0.zip -d /tmp
wget http://geonature.fr/data/inpn/taxonomie/ESPECES_REGLEMENTEES_20161103.zip
unzip ESPECES_REGLEMENTEES.zip -d /tmp
wget https://raw.githubusercontent.com/PnX-SI/TaxHub/master/data/inpn/data_inpn_v9_taxhub.sql
wget http://geonature.fr/data/inpn/taxonomie/ESPECES_REGLEMENTEES_20161103.zip
unzip ESPECES_REGLEMENTEES_20161103.zip -d /tmp
wget http://geonature.fr/data/inpn/taxonomie/LR_FRANCE_20160000.zip
unzip LR_FRANCE_20160000.zip -d /tmp

wget https://raw.githubusercontent.com/PnX-SI/TaxHub/$taxhub_release/data/inpn/data_inpn_v9_taxhub.sql
# export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f data_inpn_v9_taxhub.sql &>> ../../log/install_db.log
sudo -n -u postgres -s psql -d $db_name -f data_inpn_v9_taxhub.sql &>> ../../log/install_db.log
wget https://raw.githubusercontent.com/PnX-SI/TaxHub/master/data/vm_hierarchie_taxo.sql
sudo -n -u postgres -s psql -d $db_name -f vm_hierarchie_taxo.sql &>> ../../log/install_db.log
wget https://raw.githubusercontent.com/PnX-SI/TaxHub/master/data/taxhubdata.sql
sudo -n -u postgres -s psql -d $db_name -f taxhubdata.sql &>> ../../log/install_db.log


wget https://raw.githubusercontent.com/PnX-SI/TaxHub/$taxhub_release/data/materialized_views.sql
#sudo -n -u postgres -s psql -d $db_name -f vm_hierarchie_taxo.sql &>> ../../log/install_db.log
export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f materialized_views.sql &>> ../../log/install_db.log


wget https://raw.githubusercontent.com/PnX-SI/TaxHub/$taxhub_release/data/taxhubdata.sql
#sudo -n -u postgres -s psql -d $db_name -f taxhubdata.sql &>> ../../log/install_db.log
export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f taxhubdata.sql &>> ../../log/install_db.log


rm /tmp/*.txt
rm /tmp/*.csv
rm /tmp/*.sql
cd ../..
rm -R data/taxonomie

fi

# Creation des Vues Matérialisées (et remplacement éventuel des valeurs en dur par les paramètres)
Expand Down
1 change: 1 addition & 0 deletions main/configuration/config.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NOM_APPLICATION = "Nom de l application"
NOM_APPLICATION = unicode(NOM_APPLICATION, 'utf-8') # Fonction permettant d'encoder ce nom en utf-8, à ne pas modifier

# URL de l'application depuis la racine du domaine
# ex "/atlas" pour une URL: http://mon-domaine/atlas OU "" si l'application est accessible à la racine du domaine
URL_APPLICATION = ""

# Code de suivi des statistiques Google Analytics (si AFFICHAGE_FOOTER = True)
Expand Down
5 changes: 5 additions & 0 deletions main/configuration/settings.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ owner_atlas_pass=monpassachanger
# Installer le schéma taxonomie de TaxHub dans la BDD de GeoNature-atlas ?
install_taxonomie=false

# Version de TaxHub à utiliser pour installer le schéma taxonomie
# GeoNature-atlas 1.3.0 est compatible avec les versions de Taxhub inférieure ou égale à 1.3.2
# Numéro de version conseillée et testée : 1.3.2
taxhub_release=1.3.2

# GeoNature-atlas est-il connecté à une BDD GeoNature ?
geonature_source=true

Expand Down

0 comments on commit da66ca2

Please sign in to comment.