# -*- mode: shell-script -*- get_odoo_uid() { uid_label="odoo" odoo_uid=$(cached_cmd_on_base_image "$SERVICE_NAME" "id -u \"$uid_label\"") || { debug "Failed to query for '$uid_label' uid in ${DARKYELLOW}$SERVICE_NAME${NORMAL} base image." return 1 } info "openerp uid from ${DARKYELLOW}$SERVICE_NAME${NORMAL} is '$odoo_uid'" echo "$odoo_uid" } sql() { local dbname="$1" ( DBNAME="$(relation:get "$SERVICE_NAME":postgres-database dbname)" || return 1 ts=$(service:traverse "$SERVICE_NAME":"postgres-database") || return 1 export SERVICE_NAME="$ts" export SERVICE_DATASTORE="$DATASTORE/$SERVICE_NAME" target_charm=$(get_service_charm "$ts") || return 1 target_charm_path=$(charm.get_dir "$target_charm") || return 1 set +e . "$target_charm_path/lib/common" set -e metadata_service_def=$(_get_service_metadata "$ts") || return 1 type=$(e "$metadata_service_def" | yq -r '.type') || true if [[ "$type" != "stub" ]]; then DOCKER_BASE_IMAGE=$(service_ensure_image_ready "$SERVICE_NAME") || return 1 export DOCKER_BASE_IMAGE ensure_db_docker_running fi ddb "${dbname:-$DBNAME}" ) } odoo:get-admin-password() { local service_def config admin_password service_def=$(get_compose_service_def "$SERVICE_NAME") config=$SERVICE_CONFIGSTORE/etc/odoo-server.conf admin_password=$(echo "$service_def" | shyaml -q get-value options.admin-password) || { if [ -e "$config" ]; then admin_password=$(grep ^admin_passwd "$config" | sed -r 's/^admin_passwd\s+=\s+(.+)$/\1/g') fi if [ -z "$admin_password" ]; then err "Could not find 'admin-password' in $SERVICE_NAME service definition nor in config file." return 1 fi } echo "$admin_password" } ## XXXvlab: to include in `compose-core` get_running_container_for_service() { local containers service="$1" containers=($(get_running_containers_for_service "$service")) if [ "${#containers[@]}" == 0 ]; then err "No containers running for service $DARKYELLOW$service$NORMAL." return 1 fi if [ "${#containers[@]}" -gt 1 ]; then err "More than 1 container running for service $DARKYELLOW$service$NORMAL." echo " Please contact administrator to fix this issue." >&2 return 1 fi echo "${containers[0]}" }