You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

  1. # -*- mode: shell-script -*-
  2. get_odoo_uid() {
  3. uid_label="odoo"
  4. odoo_uid=$(cached_cmd_on_base_image "$SERVICE_NAME" "id -u \"$uid_label\"") || {
  5. debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}$SERVICE_NAME${NORMAL} base image."
  6. return 1
  7. }
  8. info "openerp uid from ${DARKYELLOW}$SERVICE_NAME${NORMAL} is '$odoo_uid'"
  9. echo "$odoo_uid"
  10. }
  11. sql() {
  12. local dbname="$1"
  13. (
  14. DBNAME="$(relation:get "$SERVICE_NAME":postgres-database dbname)" || return 1
  15. ts=$(service:traverse "$SERVICE_NAME":"postgres-database") || return 1
  16. export SERVICE_NAME="$ts"
  17. export SERVICE_DATASTORE="$DATASTORE/$SERVICE_NAME"
  18. target_charm=$(get_service_charm "$ts") || return 1
  19. target_charm_path=$(charm.get_dir "$target_charm") || return 1
  20. set +e
  21. . "$target_charm_path/lib/common"
  22. set -e
  23. metadata_service_def=$(_get_service_metadata "$ts") || return 1
  24. type=$(e "$metadata_service_def" | yq -r '.type') || true
  25. if [[ "$type" != "stub" ]]; then
  26. DOCKER_BASE_IMAGE=$(service_ensure_image_ready "$SERVICE_NAME") || return 1
  27. export DOCKER_BASE_IMAGE
  28. ensure_db_docker_running
  29. fi
  30. ddb "${dbname:-$DBNAME}"
  31. )
  32. }