Files
selfhost-cloud-compose-stack/scripts/odoo/init-odoo-with-perms.sh
2025-11-25 12:27:53 +03:30

21 lines
613 B
Bash
Executable File

#!/bin/sh
# Wrapper for odoo init: fix named volume ownership then run the original init script
set -eu
OG="$(id -u odoo 2>/dev/null || id -u):$(id -g odoo 2>/dev/null || id -g)"
echo "Fixing Odoo volumes to UID:GID=$OG"
for d in /var/lib/odoo /etc/odo; do
echo " -> chown $OG $d"
chown -R "$OG" "$d" || true
ls -ldn "$d" || true
done
echo "Running Odoo init script"
if command -v su >/dev/null 2>&1; then
echo "Dropping to 'odoo' user to run init script via su"
su -s /bin/sh odoo -c "/init-odoo.sh $*"
else
echo "su not available; running init script as current user"
exec /init-odoo.sh "$@"
fi