#!/usr/bin/env bash
set -euo pipefail

source ./0.variables.env
mkdir -p odoo-filestore odoo-logs odoo-postgresql-data custom config-postgresql config-odoo


# Downlaod des repo OCA
for repo in \
  https://github.com/OCA/account-analytic.git \
  https://github.com/OCA/account-financial-reporting.git \
  https://github.com/OCA/account-financial-tools.git \
  https://github.com/OCA/account-invoicing.git \
  https://github.com/OCA/account-payment.git \
  https://github.com/OCA/account-reconcile.git \
  https://github.com/OCA/bank-payment.git \
  https://github.com/OCA/bank-statement-import.git \
  https://github.com/OCA/community-data-files.git \
  https://github.com/OCA/currency.git \
  https://github.com/OCA/edi.git \
  https://github.com/OCA/knowledge.git \
  https://github.com/OCA/l10n-france.git \
  https://github.com/OCA/mail.git \
  https://github.com/OCA/mis-builder.git \
  https://github.com/OCA/partner-contact.git \
  https://github.com/OCA/queue.git \
  https://github.com/OCA/reporting-engine.git \
  https://github.com/OCA/sale-reporting.git \
  https://github.com/OCA/sale-workflow.git \
  https://github.com/OCA/server-auth.git \
  https://github.com/OCA/server-brand.git \
  https://github.com/OCA/server-tools.git \
  https://github.com/OCA/server-ux.git \
  https://github.com/OCA/social.git \
  https://github.com/oca/web.git 
do
  name=$(basename "$repo" .git)
  git clone -b 18.0 "$repo" "custom/$name"
  #git clone -b 18.0 "$repo"
done







# update d'odoo.conf et de docker-compose.yml annulé car remplacé par des variables directement dans les fichiers ou template
# et utilisation de la commande
# envsubst < odoo.conf.template > odoo.conf
#sed -i -E "s/^([[:space:]]*)db_port[[:space:]]*=.*/\1db_port = $POSTGRESQL_PORT/" ./odoo.conf
#sed -i "s/postgres15-5434/postgres15-$POSTGRESQL_PORT/g" ./docker-compose.yml
#sed -i "s/postgres-XXXXXXXXXXXXXXXXXXXXXX/$POSTGRES_CONTAINER/g" ./docker-compose.yml
#sed -i "s/odoo-XXXXXXXXXXXXXXXXXXXXXX/$ODOO_CONTAINER/g" ./docker-compose.yml
#sed -i -E "s/^([[:space:]]*)db_host[[:space:]]*=.*/\1db_host = $POSTGRESQL_CONTAINER/" ./odoo.conf


