#!/bin/sh set -ev # Create Postgres instance mkdir -p /srv/odoo/postgres_data chown -R 105432:105432 /srv/odoo/postgres_data chmod 700 /srv/odoo/postgres_data lxc-execute -n odoo-postgres -- initdb -D /var/lib/postgresql # Configure Postgres cp postgres_data/postgresql.conf /srv/odoo/postgres_data/postgresql.conf cp postgres_data/pg_hba.conf /srv/odoo/postgres_data/pg_hba.conf # Create databases export ODOO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') envsubst /srv/odoo/odoo_conf/odoo.conf chown 100000:100000 /srv/odoo/odoo_conf/ chown 108080:108080 /srv/odoo/odoo_data/ # Populate database # TODO: proc ne execute? lxc-start odoo -- /srv/odoo/odoo-bin -c /srv/odoo/odoo.conf -i base --load-language=cs_CZ until grep -q 'odoo.modules.loading: Modules loaded.' /var/log/lxc/odoo.log; do sleep 1 done lxc-stop odoo # Update admin account export ODOO_ADMIN_HASH=$(lxc-execute odoo -- python -c "from passlib.hash import pbkdf2_sha512;print(pbkdf2_sha512.encrypt('${ODOO_ADMIN_PWD}'))") envsubst