#!/bin/bash ## compose: no-hooks if [ -z "$SERVICE_DATASTORE" ]; then echo "This script is meant to be run through 'compose' to work properly." >&2 exit 1 fi version=0.1 usage="$exname [-h|--help] [--force|-f] [DBNAME]" help=" USAGE: $usage DESCRIPTION: Outputs to stdout the odoo zip dump of DBNAME. If DBNAME is not provided, it'll take the default odoo database from the ${DARKCYAN}postgres-database${NORMAL} relation of current service. EXAMPLES: $exname > dump.zip $exname odoo2 > odoo2.zip " dbname= output= while [ "$1" ]; do case "$1" in "--help"|"-h") print_help >&2 exit 0 ;; "--force"|"-f") force=yes ;; --*|-*) err "Unexpected optional argument '$1'" print_usage >&2 exit 1 ;; *) [ -z "$dbname" ] && { dbname=$1 ; shift ; continue ; } err "Unexpected positional argument '$1'" print_usage >&2 exit 1 ;; esac shift done if [ -z "$dbname" ]; then dbname=$(relation:get "$SERVICE_NAME:postgres-database" dbname) || { err "Couldn't retrieve information of" \ "${DARKYELLOW}$SERVICE_NAME${NORMAL}-->${DARKCYAN}postgres-database${NORMAL}." exit 1 } fi . $CHARM_PATH/lib/common set -e odoo:save "$dbname"