When a odoo user already exists, the installation of the deb package fails because the `/var/lib/odoo` directory does not exists. The reason is that the postinst script is trying to change the permissions of this directory which is only created if a odoo user does not already exists. With this commit, the permission changes only occurs when the directory is created. closes odoo/odoo#111877 X-original-commit: 8e1ebd8de01bc9d97e47572bc8b1d2eaafebf743 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
35 lines
885 B
Bash
35 lines
885 B
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
ODOO_CONFIGURATION_FILE=/etc/odoo/odoo.conf
|
|
ODOO_GROUP="odoo"
|
|
ODOO_DATA_DIR=/var/lib/odoo
|
|
ODOO_LOG_DIR=/var/log/odoo
|
|
ODOO_USER="odoo"
|
|
|
|
case "${1}" in
|
|
configure)
|
|
if ! getent passwd | grep -q "^odoo:"; then
|
|
adduser --system --home $ODOO_DATA_DIR --quiet --group $ODOO_USER
|
|
# Data dir
|
|
chown $ODOO_USER:$ODOO_GROUP $ODOO_DATA_DIR
|
|
fi
|
|
# Register "$ODOO_USER" as a postgres user with "Create DB" role attribute
|
|
su - postgres -c "createuser -d -R -S $ODOO_USER" 2> /dev/null || true
|
|
# Configuration file
|
|
chown $ODOO_USER:$ODOO_GROUP $ODOO_CONFIGURATION_FILE
|
|
chmod 0640 $ODOO_CONFIGURATION_FILE
|
|
# Log
|
|
mkdir -p $ODOO_LOG_DIR
|
|
chown $ODOO_USER:$ODOO_GROUP $ODOO_LOG_DIR
|
|
chmod 0750 $ODOO_LOG_DIR
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|