Introduce Odoo application package

This commit is contained in:
Disassembler 2018-11-17 22:08:10 +01:00
parent aecf3eede2
commit 1dce7601cf
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
11 changed files with 147 additions and 1 deletions

View File

@ -103,6 +103,7 @@ The full build process takes considerable amount of time, so it is advised to ha
| Motech | motech | 8013 | 8080 (HTTP) | motech | | Motech | motech | 8013 | 8080 (HTTP) | motech |
| ODK Aggregate | opendatakit | 8015 | 8080 (HTTP) | odk | | ODK Aggregate | opendatakit | 8015 | 8080 (HTTP) | odk |
| ODK Build | opendatakit-build | 8017 | 8080 (HTTP) | odkbuild | | ODK Build | opendatakit-build | 8017 | 8080 (HTTP) | odkbuild |
| Odoo | odoo | 8019 | 8080 (HTPP) | odoo |
| OpenMapKit | openmapkit | 8007 | 8080 (HTTP) | omk | | OpenMapKit | openmapkit | 8007 | 8080 (HTTP) | omk |
| Pan.do/ra | pandora | 8002 | 8080 (HTTP) | pandora | | Pan.do/ra | pandora | 8002 | 8080 (HTTP) | pandora |
| Postgres | postgres | 5432 | 5432 (Postgres) | - | | Postgres | postgres | 5432 | 5432 (Postgres) | - |

@ -1 +1 @@
Subproject commit 6a68be739ab7ba6c55d79c9abf7744b6eaa35cf7 Subproject commit be5e95d5c0389ef024359cf4885a0a5792363c05

41
odoo/install.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
set -ev
cd $(realpath $(dirname "${0}"))/install
# Check prerequisites
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
# Create databases
export ODOO_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 postgres -- psql
# Configure Odoo
export ODOO_ADMIN_USER="admin"
export ODOO_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
mkdir -p /srv/odoo/conf/ /srv/odoo/data/
chown 8019:8019 /srv/odoo/data/
envsubst <srv/odoo/conf/odoo.conf >/srv/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
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 postgres -- psql odoo
# Install service
cp etc/init.d/odoo /etc/init.d/odoo
rc-update -u
# Stop services required for setup
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
# Register application
vmmgr register-app odoo "${ODOO_ADMIN_USER}" "${ODOO_ADMIN_PWD}"
exit 0

View File

@ -0,0 +1,3 @@
UPDATE res_lang SET active = true WHERE code = 'cs_CZ';
UPDATE res_partner SET lang = 'cs_CZ', tz = 'Europe/Prague' WHERE id = 3;
UPDATE res_users SET password = '${ODOO_ADMIN_HASH}' WHERE login = 'admin';

View File

@ -0,0 +1,4 @@
CREATE ROLE odoo NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${ODOO_PWD}';
CREATE DATABASE odoo;
REVOKE ALL ON DATABASE odoo FROM public;
ALTER DATABASE odoo OWNER TO odoo;

23
odoo/install/etc/init.d/odoo Executable file
View File

@ -0,0 +1,23 @@
#!/sbin/openrc-run
description="Odoo container"
depend() {
need postgres
}
start() {
lxc-start odoo
}
start_post() {
/usr/bin/vmmgr register-proxy odoo
}
stop_pre() {
/usr/bin/vmmgr unregister-proxy odoo
}
stop() {
lxc-stop odoo
}

View File

@ -0,0 +1,12 @@
[options]
admin_passwd = ${ODOO_ADMIN_PWD}
data_dir = /srv/odoo/data
db_host = postgres
db_name = odoo
db_password = ${ODOO_PWD}
db_user = odoo
email_from = admin@example.com
http_port = 8080
list_db = False
proxy_mode = True
smtp_server = host

View File

@ -0,0 +1,3 @@
#!/bin/sh
sed -i "s|\(^email_from = \).*|\1${EMAIL}|" /srv/odoo/conf/odoo.conf

39
odoo/lxcfile Normal file
View File

@ -0,0 +1,39 @@
IMAGE odoo
LAYER shared/alpine
LAYER shared/libxml
LAYER shared/python3
LAYER shared/nodejs
LAYER odoo/odoo
FIXLAYER /usr/bin/fix-apk
RUN EOF
# Install runtime dependencies
apk --no-cache add libjpeg-turbo libpq
# Install build dependencies
apk --no-cache add --virtual .deps build-base git libjpeg-turbo-dev libxml2-dev libxslt-dev linux-headers openldap-dev postgresql-dev python3-dev
# Clone Odoo repository
git clone --depth 1 https://github.com/odoo/odoo.git /srv/odoo
# Install Odoo
cd /srv/odoo
pip3 install -r requirements.txt
# Create OS user
addgroup -S -g 8019 odoo
adduser -S -u 8019 -h /srv/odoo -s /bin/false -g odoo -G odoo odoo
chown -R odoo:odoo /srv/odoo
# Cleanup
apk --no-cache del .deps
find /srv/odoo -name '.git*' -exec rm -rf {} +
rm -rf /usr/local/share/.cache
EOF
MOUNT FILE /srv/odoo/conf/odoo.conf srv/odoo/odoo.conf
MOUNT DIR /srv/odoo/data srv/odoo/data
USER 8019 8019
CMD /srv/odoo/odoo-bin -c srv/odoo/odoo.conf

7
odoo/pkg Normal file
View File

@ -0,0 +1,7 @@
pkg: odoo
title: Odoo
lxcpath: odoo
desc: Sada aplikací pro správu organizace
host: odoo
version: 0.0.1
deps: python3 nodejs postgres

13
odoo/uninstall.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
set -ev
# Remove service
rm -f /etc/init.d/odoo
rc-update -u
# Drop database and user
[ ! -e /run/openrc/started/postgres ] && service postgres start && STOP_POSTGRES=1
echo 'DROP DATABASE IF EXISTS odoo; DROP ROLE IF EXISTS odoo;' | lxc-attach -u 5432 -g 5432 postgres -- psql
[ ! -z ${STOP_POSTGRES} ] && service postgres stop
exit 0