Ajout : etc/sv/ : $HTTP_OPENERP_DB_FILTER .
authorJulien Moutinho <julm+heureux-cyclage@autogeree.net>
Sun, 1 Dec 2013 04:43:58 +0000 (05:43 +0100)
committerroot <root@ateliers.heureux-cyclage.org>
Sun, 1 Dec 2013 04:44:33 +0000 (05:44 +0100)
etc/nginx/site.d/burette/http.conf
etc/nginx/site.d/burette/site.conf
etc/sv/openerp7_burette/run

index a98f0b1..a0d1cf7 100644 (file)
@@ -8,7 +8,11 @@ server {
         burette.dynamo.heureux-cyclage.org
         burette.ptitvelo.heureux-cyclage.org
         burette.ptitvelo.net
-        burette.velosenville.org;
+        burette.velorution.org
+        burette.velorution_idf.heureux-cyclage.org
+        burette.velosenville.org
+        burette.vieuxbiclou.heureux-cyclage.org
+        burette.vieuxbiclou.org;
        
        return 301 https://$host$request_uri;
  }
@@ -17,3 +21,19 @@ upstream openerp7_burette {
         fail_timeout=300s
         weight=1;
  }
+map $http_host $burette_dbfilter {
+       default                                    "";
+       burettes.heureux-cyclage.org               ".*$";
+       burette.atelierdynamo.fr                   "dynamo$";
+       burette.cyclocoop.heureux-cyclage.org      "cyclo_.*$";
+       burette.cyclocoop.org                      "cyclo_.*$";
+       burette.dynamo.heureux-cyclage.org         "dynamo$";
+       burette.ptitvelo.heureux-cyclage.org       "ptitvelo$";
+       burette.ptitvelo.net                       "ptitvelo$";
+       burette.velorution.org                     "velorution_idf$";
+       burette.velorution_idf.heureux-cyclage.org "velorution_idf$";
+       burette.velosenville.heureux-cyclage.org   "velosenville$";
+       burette.velosenville.org                   "velosenville$";
+       burette.vieuxbiclou.heureux-cyclage.org    "vieuxbiclou$";
+       burette.vieuxbiclou.org                    "vieuxbiclou$";
+ }
index 191b13e..ed68b6e 100644 (file)
@@ -6,9 +6,11 @@ server_name
  burette.dynamo.heureux-cyclage.org
  burette.ptitvelo.heureux-cyclage.org
  burette.ptitvelo.net
- demo.burette.ptitvelo.net
+ burette.velorution.org
+ burette.velorution_idf.heureux-cyclage.org
  burette.velosenville.org
- demo.burette.velosenville.org;
+ burette.vieuxbiclou.heureux-cyclage.org
+ burette.vieuxbiclou.org;
 
 client_body_buffer_size 1024k;
 client_max_body_size 10m;
@@ -33,6 +35,9 @@ location / {
                # NOTE: by default, do not forward anything
        proxy_read_timeout 500;
        proxy_set_header Host $host;
+       proxy_set_header OpenERP-DB-Filter $burette_dbfilter;
+               # TODO: utiliser un certificat utilisateurice X.509
+               # pour initialiser cette variable.
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
                # NOTE: let the OpenERP web service know that we're using HTTPS,
index b598bea..822c081 100755 (executable)
@@ -7,6 +7,22 @@ cd /
 export LOGNAME="$sv"
  # NOTE: openerp utilise /tmp/oe-sessions-$LOGNAME
 
+/bin/grep --fixed-strings --quiet --word-regexp HTTP_OPENERP_DB_FILTER \
+ /usr/share/pyshared/openerp/addons/web/controllers/main.py ||
+/usr/bin/patch --forward --reject-file=- --strip=0 --unified <<-EOF
+       --- /usr/share/pyshared/openerp/addons/web/controllers/main.py  2013-12-01 05:06:50.121954391 +0100
+       +++ /usr/share/pyshared/openerp/addons/web/controllers/main.py  2013-12-01 05:07:44.917954389 +0100
+       @@ -90,6 +90,8 @@
+            h = req.httprequest.environ['HTTP_HOST'].split(':')[0]
+            d = h.split('.')[0]
+            r = openerp.tools.config['dbfilter'].replace('%h', h).replace('%d', d)
+       +    f = req.httprequest.environ['HTTP_OPENERP_DB_FILTER']
+       +    r = r.replace('%f', f)
+            dbs = [i for i in dbs if re.match(r, i)]
+            return dbs
+        
+       EOF
+
 for db in \
  cyclo_ivry \
  cyclo_pantin \
@@ -51,4 +67,5 @@ exec /usr/bin/chpst \
  /usr/bin/openerp-server \
  --config /etc/openerp/"$version"/"${sv#openerp7_}"/server.conf \
  --load-language=fr_FR \
+ --db-filter="^${sv}_%f" \
  "$@"