Files
odoocker/odoo/entrypoint.sh

98 lines
4.2 KiB
Bash
Raw Permalink Normal View History

2023-04-19 14:27:50 -05:00
#!/bin/bash
set -e
2023-10-01 00:55:06 -05:00
while IFS='=' read -r key value || [[ -n $key ]]; do
# Skip comments and empty lines
[[ $key =~ ^#.* ]] || [[ -z $key ]] && continue
# Removing any quotes around the value
value=${value%\"}
value=${value#\"}
# Declare variable
eval "$key=\"$value\""
done < .env
2023-10-20 01:07:27 -05:00
# Check the USE_REDIS to add base_attachment_object_storage & session_redis to LOAD variable
2023-10-20 00:57:28 -05:00
if [[ $USE_REDIS == "true" ]]; then
LOAD+=",session_redis"
fi
2023-10-20 01:07:27 -05:00
# Check the USE_REDIS to add attachment_s3 to LOAD variable
2023-10-20 00:57:28 -05:00
if [[ $USE_S3 == "true" ]]; then
2023-10-20 01:09:20 -05:00
LOAD+=",base_attachment_object_storage"
2023-10-20 00:57:28 -05:00
LOAD+=",attachment_s3"
fi
2023-10-20 01:07:27 -05:00
# Check the USE_REDIS to add sentry to LOAD variable
2023-10-20 00:57:28 -05:00
if [[ $USE_SENTRY == "true" ]]; then
LOAD+=",sentry"
fi
2023-04-19 14:27:50 -05:00
case "$1" in
-- | odoo)
shift
if [[ "$1" == "scaffold" ]] ; then
# Creates new module.
exec odoo "$@"
else
2023-10-01 00:55:06 -05:00
wait-for-psql.py --db_host ${HOST} --db_port ${PORT} --db_user ${USER} --db_password ${PASSWORD} --timeout=30
2023-04-19 14:27:50 -05:00
if [ ${APP_ENV} = 'fresh' ] || [ ${APP_ENV} = 'restore' ]; then
2023-08-26 16:23:45 -05:00
# Ideal for a fresh install or restore a production database.
2023-10-20 00:07:37 -05:00
echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${LOAD} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200
2023-04-19 14:27:50 -05:00
2023-08-26 16:23:45 -05:00
exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200
2023-04-19 14:27:50 -05:00
fi
if [ ${APP_ENV} = 'local' ] ; then
2023-08-26 16:23:45 -05:00
# Listens to all .env variables mapped into odoo.conf file.
2023-10-20 00:07:37 -05:00
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${LOAD} --workers=${WORKERS} --log-level=${LOG_LEVEL} --dev=${DEV_MODE}
2023-04-19 14:27:50 -05:00
2023-12-12 18:57:24 -07:00
exec odoo --config ${ODOO_RC} --init=${INIT} --update=${UPDATE} --dev=${DEV_MODE}
2023-04-19 14:27:50 -05:00
fi
2023-04-20 19:48:58 -05:00
if [ ${APP_ENV} = 'debug' ] ; then
2023-08-26 16:23:45 -05:00
# Same as local but you can debug you custom addons with your code editor (VSCode).
echo debugpy odoo --config ${ODOO_RC}
2023-04-20 19:48:58 -05:00
2023-08-26 16:23:45 -05:00
exec /usr/bin/python3 -m debugpy --listen ${DEBUG_INTERFACE}:${DEBUG_PORT} ${DEBUG_PATH} --config ${ODOO_RC}
2023-04-20 19:48:58 -05:00
fi
2023-04-19 14:27:50 -05:00
if [ ${APP_ENV} = 'testing' ] ; then
2023-08-26 16:23:45 -05:00
# Initializies a fresh 'test_*' database, installs the addons to test, and runs tests you specify in the test tags.
2023-10-20 00:07:37 -05:00
echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${LOAD} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --dev= --stop-after-init
2023-04-19 14:27:50 -05:00
2023-10-01 00:55:06 -05:00
exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --without-demo= --workers=0 --dev= --stop-after-init
2023-04-19 14:27:50 -05:00
fi
if [ ${APP_ENV} = 'staging' ] ; then
2023-08-26 16:23:45 -05:00
# Automagically upgrade all addons and install new ones. Ideal for deployment process.
2023-10-20 00:07:37 -05:00
echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${LOAD} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --dev=
2023-04-19 14:27:50 -05:00
exec odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --without-demo=all --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 --dev=
2023-04-19 14:27:50 -05:00
fi
if [ ${APP_ENV} = 'production' ] ; then
2023-08-25 02:08:56 -05:00
# Bring up Odoo ready for production.
echo odoo --config ${ODOO_RC} --database= --init=${INIT} --update=${UPDATE} --load=${LOAD} --workers=${WORKERS} --log-level=${LOG_LEVEL} --without-demo=${WITHOUT_DEMO} --load-language= --dev=
2023-04-19 14:27:50 -05:00
exec odoo --config ${ODOO_RC} --database= --init=${INIT} --update=${UPDATE} --load-language= --dev=
2023-04-19 14:27:50 -05:00
fi
fi
;;
-*)
2023-08-26 16:23:45 -05:00
2023-10-01 00:55:06 -05:00
wait-for-psql.py --db_host ${HOST} --db_port ${PORT} --db_user ${USER} --db_password ${PASSWORD} --timeout=30
2023-04-19 14:27:50 -05:00
echo odoo --config ${ODOO_RC}
exec odoo --config ${ODOO_RC}
;;
*)
echo "$@"
exec "$@"
esac
2023-08-25 02:08:56 -05:00
exit 1