48 lines
1.6 KiB
Bash
Executable File
48 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
set -ev
|
|
|
|
cd $(realpath $(dirname "${0}"))/install
|
|
|
|
# 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 <createdb.sql | lxc-attach -u 5432 -g 5432 odoo-postgres -- psql
|
|
|
|
# Configure Odoo
|
|
export ODOO_ADMIN_USER="admin"
|
|
export ODOO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
|
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/
|
|
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 <adminpwd.sql | lxc-attach -u 5432 -g 5432 odoo-postgres -- psql odoo
|
|
|
|
# Install config update script
|
|
cp update-conf.sh /srv/odoo/update-conf.sh
|
|
|
|
# Stop services required for setup
|
|
service odoo-postgres stop
|
|
|
|
# Register application
|
|
vmmgr register-app odoo odoo "${ODOO_ADMIN_USER}" "${ODOO_ADMIN_PWD}"
|