From 13d29c212d478fa1e3c0fba78393edf137e10881 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 11 Jul 2018 11:27:54 +0200 Subject: [PATCH] new: [odoo-tecnativa] added charm --- odoo-tecnativa/README.rst | 8 +++ odoo-tecnativa/hooks/init | 25 +++++++++ .../hooks/postgres_database-relation-joined | 51 +++++++++++++++++++ .../hooks/web_proxy-relation-joined | 11 ++++ odoo-tecnativa/lib/common | 11 ++++ odoo-tecnativa/metadata.yml | 29 +++++++++++ 6 files changed, 135 insertions(+) create mode 100644 odoo-tecnativa/README.rst create mode 100755 odoo-tecnativa/hooks/init create mode 100755 odoo-tecnativa/hooks/postgres_database-relation-joined create mode 100755 odoo-tecnativa/hooks/web_proxy-relation-joined create mode 100644 odoo-tecnativa/lib/common create mode 100644 odoo-tecnativa/metadata.yml diff --git a/odoo-tecnativa/README.rst b/odoo-tecnativa/README.rst new file mode 100644 index 0000000..949ff9a --- /dev/null +++ b/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. + diff --git a/odoo-tecnativa/hooks/init b/odoo-tecnativa/hooks/init new file mode 100755 index 0000000..e549a07 --- /dev/null +++ b/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" diff --git a/odoo-tecnativa/hooks/postgres_database-relation-joined b/odoo-tecnativa/hooks/postgres_database-relation-joined new file mode 100755 index 0000000..802e1c3 --- /dev/null +++ b/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 <