Browse Source

new: [odoo-tecnativa] added charm

postgres
Valentin Lab 6 years ago
parent
commit
13d29c212d
  1. 8
      odoo-tecnativa/README.rst
  2. 25
      odoo-tecnativa/hooks/init
  3. 51
      odoo-tecnativa/hooks/postgres_database-relation-joined
  4. 11
      odoo-tecnativa/hooks/web_proxy-relation-joined
  5. 11
      odoo-tecnativa/lib/common
  6. 29
      odoo-tecnativa/metadata.yml

8
odoo-tecnativa/README.rst

@ -0,0 +1,8 @@
Odoo-tecnativa is a odoo image containing all source and add-ons because
we want to certify the whole image.
So this means there are no builds being managed by compose, and no injection
of code.

25
odoo-tecnativa/hooks/init

@ -0,0 +1,25 @@
#!/bin/bash
## Init is run on host
## For now it is run every time the script is launched, but
## it should be launched only once after build.
## Accessible variables are:
## - SERVICE_NAME Name of current service
## - DOCKER_BASE_IMAGE Base image from which this service might be built if any
## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
LIB="$SERVICE_DATASTORE/var/lib/odoo"
. lib/common
set -e
odoo_uid=$(get_odoo_uid)
mkdir -p "$LIB"
## XXXvlab: this one can fail if files are removed (from sessions dir)
chown -R "$odoo_uid" "$LIB" || true
# setfacl -R -m "u:$odoo_uid:rx" "/opt/apps/0k-oe"

51
odoo-tecnativa/hooks/postgres_database-relation-joined

@ -0,0 +1,51 @@
#!/bin/bash
## XXXvlab: this hook should go into a generic odoo image
## XXXvlab: should get location of code
CONFIG=$SERVICE_CONFIGSTORE/etc/odoo-server.conf
. lib/common
set -e
PASSWORD="$(relation-get password)"
USER="$(relation-get user)"
DBNAME="$(relation-get dbname)"
ADMIN_PASSWORD=$(relation-base-compose-get admin-password)
control=$(echo -en "$USER\0$DBNAME\0$PASSWORD\0$ADMIN_PASSWORD" | md5_compat)
config-add "\
services:
$MASTER_BASE_CHARM_NAME:
command:
- '--database=$DBNAME'
## All this is to please technativa image, but is quite redundant
environment:
PGHOST: $MASTER_TARGET_CHARM_NAME
PGDATABASE: $DBNAME
PGPASSWORD: $PASSWORD
PGUSER: $USER
#DBFILTER: $DBNAME
ADMIN_PASSWORD: $ADMIN_PASSWORD
"
[ "$control" == "$(relation-get control 2>/dev/null)" ] && exit 0
file_put $CONFIG <<EOF
[options]
admin_passwd = $ADMIN_PASSWORD
db_user = $USER
db_password = $PASSWORD
EOF
odoo_uid=$(get_odoo_uid)
chown "$odoo_uid" "$CONFIG" && chmod 600 "$CONFIG"
relation-set control "$control"
info "Configured $SERVICE_NAME code for $TARGET_SERVICE_NAME access."

11
odoo-tecnativa/hooks/web_proxy-relation-joined

@ -0,0 +1,11 @@
#!/bin/bash
set -e
config-add "\
services:
$MASTER_BASE_CHARM_NAME:
environment:
PROXY_MODE: \"true\"
"

11
odoo-tecnativa/lib/common

@ -0,0 +1,11 @@
# -*- mode: shell-script -*-
get_odoo_uid() {
uid_label="odoo"
odoo_uid=$(cached_cmd_on_base_image odoo "id -u \"$uid_label\"") || {
debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}odoo${NORMAL} base image."
return 1
}
info "openerp uid from ${DARKYELLOW}odoo${NORMAL} is '$odoo_uid'"
echo "$odoo_uid"
}

29
odoo-tecnativa/metadata.yml

@ -0,0 +1,29 @@
docker-image: git.panda-chi.io:5002/panda-chi/docker-odoo-pandachi:11.0-all-module-test
data-resources:
- /var/lib/odoo
- /var/log/odoo
# config-resources:
# ## XXXvlab: should this be there or declared dynamically in the relation that
# ## create/update this file ?
# # - /etc/odoo-server.conf
docker-compose:
command:
- odoo
- --config=/opt/odoo/auto/odoo.conf
- --workers=0
# XXX Odoo v8 has no `--dev` mode; Odoo v9 has no parameters
- --dev=reload,qweb,werkzeug,xml,wdb
## YYYvlab: useful ?
tty: true
environment:
INITIAL_LANG: fr_FR
# network-isolation:
# whitelist: ## required external services used by this service
# - www.google.com
# - www.gravatar.com
# - fonts.gstatic.com
# - fonts.googleapis.com
# - cdnjs.cloudflare.com
Loading…
Cancel
Save