2018-11-17 22:08:10 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -ev
|
|
|
|
|
2020-03-20 20:22:27 +01:00
|
|
|
# Volumes
|
|
|
|
POSTGRES_DATA="${VOLUMES_DIR}/odoo/postgres_data"
|
|
|
|
ODOO_CONF="${VOLUMES_DIR}/odoo/odoo_conf"
|
|
|
|
ODOO_DATA="${VOLUMES_DIR}/odoo/odoo_data"
|
|
|
|
|
2019-10-03 21:53:42 +02:00
|
|
|
# Create Postgres instance
|
2020-03-20 20:22:27 +01:00
|
|
|
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
|
|
|
spoc-container exec odoo-postgres -- initdb -D /var/lib/postgresql
|
2019-10-03 21:53:42 +02:00
|
|
|
|
|
|
|
# Configure Postgres
|
2020-03-20 20:22:27 +01:00
|
|
|
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
|
|
|
|
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Create databases
|
2019-06-05 18:55:15 +02:00
|
|
|
export ODOO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-20 20:22:27 +01:00
|
|
|
spoc-container start odoo-postgres
|
|
|
|
envsubst <createdb.sql | spoc-container exec odoo-postgres -- psql
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Configure Odoo
|
|
|
|
export ODOO_ADMIN_USER="admin"
|
2019-06-05 18:55:15 +02:00
|
|
|
export ODOO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
2020-03-20 20:22:27 +01:00
|
|
|
install -o 108080 -g 108080 -m 750 -d ${ODOO_CONF}
|
|
|
|
install -o 108080 -g 108080 -m 750 -d ${ODOO_DATA}
|
|
|
|
envsubst <odoo_conf/odoo.conf | install -o 108080 -g 108080 -m 640 /dev/stdin ${ODOO_CONF}/odoo.conf
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Populate database
|
2020-03-20 20:22:27 +01:00
|
|
|
spoc-container exec odoo -- /srv/odoo/odoo-bin -c /srv/odoo/odoo.conf -i base --load-language=cs_CZ &
|
|
|
|
ODOO_PID=$!
|
|
|
|
until grep -q 'odoo.modules.loading: Modules loaded.' /var/log/spoc/odoo.log; do
|
2018-11-17 22:08:10 +01:00
|
|
|
sleep 1
|
|
|
|
done
|
2020-03-20 20:22:27 +01:00
|
|
|
kill ${ODOO_PID}
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Update admin account
|
2020-03-20 22:32:46 +01:00
|
|
|
export ODOO_ADMIN_HASH=$(spoc-container exec odoo -- python -c "from passlib.hash import pbkdf2_sha512;print(pbkdf2_sha512.hash('${ODOO_ADMIN_PWD}'))")
|
2020-03-20 20:22:27 +01:00
|
|
|
envsubst <adminpwd.sql | spoc-container exec odoo-postgres -- psql odoo
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Stop services required for setup
|
2020-03-20 20:22:27 +01:00
|
|
|
spoc-container stop odoo-postgres
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Register application
|
2019-02-26 21:12:41 +01:00
|
|
|
vmmgr register-app odoo odoo "${ODOO_ADMIN_USER}" "${ODOO_ADMIN_PWD}"
|