Make Odoo SPOC-compatible

This commit is contained in:
Disassembler 2020-03-20 20:22:27 +01:00
parent 590dde8206
commit 0790a9243b
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
5 changed files with 52 additions and 52 deletions

27
lxc-apps/odoo/app Normal file
View File

@ -0,0 +1,27 @@
{
"version": "13.0.0-200313",
"meta": {
"title": "Odoo",
"desc-cs": "Sada aplikací pro správu organizace",
"desc-en": "Company management application suite",
"license": "GPL"
},
"containers": {
"odoo": {
"image": "odoo_13.0.0-200313",
"depends": [
"odoo-postgres"
],
"mounts": {
"odoo/odoo_data": "srv/odoo/data",
"odoo/odoo_conf/odoo.conf": "srv/odoo/odoo.conf:file"
}
},
"odoo-postgres": {
"image": "postgres_12.2.0-200313",
"mounts": {
"odoo/postgres_data": "var/lib/postgresql"
}
}
}
}

View File

@ -1,5 +1,5 @@
IMAGE odoo_13.0.0-191113
FROM alpine3.9-python3.6_3.6.8-190620
IMAGE odoo_13.0.0-200313
FROM alpine3.11-python3.8_3.8.2-200313
RUN EOF
# Install runtime dependencies
@ -26,5 +26,5 @@ RUN EOF
rm -rf /usr/local/share/.cache
EOF
USER 8080 8080
USER odoo
CMD /srv/odoo/odoo-bin -c srv/odoo/odoo.conf

View File

@ -1,45 +1,45 @@
#!/bin/sh
set -ev
# Volumes
POSTGRES_DATA="${VOLUMES_DIR}/odoo/postgres_data"
ODOO_CONF="${VOLUMES_DIR}/odoo/odoo_conf"
ODOO_DATA="${VOLUMES_DIR}/odoo/odoo_data"
# 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
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
spoc-container exec 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
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
# Create databases
export ODOO_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-odoo-postgres start
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 odoo-postgres -- psql
spoc-container start odoo-postgres
envsubst <createdb.sql | spoc-container exec 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/
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
# 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
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
sleep 1
done
lxc-stop odoo
kill ${ODOO_PID}
# 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
export ODOO_ADMIN_HASH=$(spoc-container exec odoo -- python -c "from passlib.hash import pbkdf2_sha512;print(pbkdf2_sha512.encrypt('${ODOO_ADMIN_PWD}'))")
envsubst <adminpwd.sql | spoc-container exec odoo-postgres -- psql odoo
# Stop services required for setup
service lxc-odoo-postgres stop
spoc-container stop odoo-postgres
# Register application
vmmgr register-app odoo odoo "${ODOO_ADMIN_USER}" "${ODOO_ADMIN_PWD}"

View File

@ -1,27 +0,0 @@
{
"version": "13.0.0-191113",
"meta": {
"title": "Odoo",
"desc-cs": "Sada aplikací pro správu organizace",
"desc-en": "Company management application suite",
"license": "GPL"
},
"containers": {
"odoo": {
"image": "odoo_13.0.0-191113",
"depends": [
"odoo-postgres"
],
"mounts": [
["DIR", "/srv/odoo/odoo_data", "/srv/odoo/data"],
["FILE", "/srv/odoo/odoo_conf/odoo.conf", "/srv/odoo/odoo.conf"]
]
},
"odoo-postgres": {
"image": "postgres_11.3.0-190620",
"mounts": [
["DIR", "/srv/odoo/postgres_data", "/var/lib/postgresql"]
]
}
}
}

View File

@ -2,7 +2,7 @@
set -ev
# Remove persistent data
rm -rf /srv/odoo
rm -rf "${VOLUMES_DIR}/odoo"
# Unregister application
vmmgr unregister-app odoo