forked from 0k/0k-charms
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
#!/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."
|