docker-entrypoint.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. set -e
  3. # set the postgres database host, port, user and password according to the environment
  4. # and pass them as arguments to the Odoo process if not present in the config file
  5. : ${PSQL_HOST:=${DB_PORT_5432_TCP_ADDR:='db'}}
  6. : ${PSQL_PORT:=${DB_PORT_5432_TCP_PORT:=5432}}
  7. : ${PSQL_USER:=${DB_ENV_POSTGRES_USER:=${POSTGRES_USER:='odoo'}}}
  8. : ${PSQL_PASSWORD:=${DB_ENV_POSTGRES_PASSWORD:=${POSTGRES_PASSWORD:='odoo'}}}
  9. DB_ARGS=("--config=${ODOO_CONFIG}" "--workers=0" "--dev" "--debug")
  10. ADDONS=("/opt/odoo/openerp/addons" "/opt/odoo/addons" "/mnt/repos")
  11. # Install requirements.txt and oca_dependencies.txt from root of mount
  12. if [[ "${SKIP_DEPENDS}" != "1" ]] ; then
  13. export VERSION=$ODOO_VERSION
  14. clone_oca_dependencies /mnt/repos /tmp
  15. # Iterate the newly cloned addons & add into possible dirs
  16. for dir in /opt/odoo/repos/*/ ; do
  17. ADDONS+=("$dir")
  18. done
  19. VALID_ADDONS="$(getaddons.py ${ADDONS[*]})"
  20. DB_ARGS+=("--addons-path=${VALID_ADDONS}")
  21. fi
  22. # Pull database from config file if present & validate
  23. function check_config() {
  24. param="$1"
  25. value="$2"
  26. if ! grep -q -E "^\s*\b${param}\b\s*=" "$ODOO_CONFIG" ; then
  27. DB_ARGS+=("--${param}")
  28. DB_ARGS+=("${value}")
  29. fi;
  30. }
  31. check_config "db_host" "$PSQL_HOST"
  32. check_config "db_port" "$PSQL_PORT"
  33. check_config "db_user" "$PSQL_USER"
  34. check_config "db_password" "$PSQL_PASSWORD"
  35. # Execute
  36. case "$1" in
  37. -- | openerp-server)
  38. shift
  39. if [[ "$1" == "scaffold" ]] ; then
  40. su-exec odoo /opt/odoo/odoo.py "$@"
  41. else
  42. su-exec odoo /opt/odoo/odoo.py "$@" "${DB_ARGS[@]}"
  43. fi
  44. ;;
  45. -*)
  46. su-exec odoo /opt/odoo/odoo.py "$@" "${DB_ARGS[@]}"
  47. ;;
  48. *)
  49. "$@"
  50. esac
  51. exit 1