2018-11-17 22:08:10 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -ev
|
|
|
|
|
2019-10-03 21:53:42 +02:00
|
|
|
# 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
|
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 '+/=')
|
2019-11-13 21:01:27 +01:00
|
|
|
service odoo-postgres start
|
2019-10-03 21:53:42 +02:00
|
|
|
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 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 '+/=')
|
2019-10-03 21:53:42 +02:00
|
|
|
mkdir -p /srv/odoo/odoo_conf/ /srv/odoo/odoo_data/
|
|
|
|
envsubst <odoo_conf/odoo.conf >/srv/odoo/odoo_conf/odoo.conf
|
|
|
|
chown 100000:100000 /srv/odoo/odoo_conf/
|
2019-10-14 07:59:06 +02:00
|
|
|
chown 108080:108080 /srv/odoo/odoo_data/
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Populate database
|
|
|
|
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}'))")
|
2019-10-03 21:53:42 +02:00
|
|
|
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 odoo-postgres -- psql odoo
|
2018-11-17 22:08:10 +01:00
|
|
|
|
2019-10-03 21:53:42 +02:00
|
|
|
# Install config update script
|
|
|
|
cp update-conf.sh /srv/odoo/update-conf.sh
|
2018-11-17 22:08:10 +01:00
|
|
|
|
|
|
|
# Stop services required for setup
|
2019-10-03 21:53:42 +02:00
|
|
|
service odoo-postgres stop
|
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}"
|