Skip to content

Commit

Permalink
[FIX] packaging: fix installing deb package when user exists
Browse files Browse the repository at this point in the history
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#111877

X-original-commit: 8e1ebd8
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
  • Loading branch information
d-fence committed Feb 3, 2023
1 parent 7a4a836 commit a5d878a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ 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
Expand All @@ -22,8 +24,6 @@ case "${1}" in
mkdir -p $ODOO_LOG_DIR
chown $ODOO_USER:$ODOO_GROUP $ODOO_LOG_DIR
chmod 0750 $ODOO_LOG_DIR
# Data dir
chown $ODOO_USER:$ODOO_GROUP $ODOO_DATA_DIR
;;
*)
;;
Expand Down

0 comments on commit a5d878a

Please sign in to comment.