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.

70 lines
1.3 KiB

  1. #!/bin/bash
  2. ## compose: no-hooks
  3. if [ -z "$SERVICE_DATASTORE" ]; then
  4. echo "This script is meant to be run through 'compose' to work properly." >&2
  5. exit 1
  6. fi
  7. version=0.1
  8. usage="$exname [-h|--help] [--force|-f] [DBNAME]"
  9. help="
  10. USAGE:
  11. $usage
  12. DESCRIPTION:
  13. Outputs to stdout the odoo zip dump of DBNAME. If DBNAME is not
  14. provided, it'll take the default odoo database from the
  15. ${DARKCYAN}postgres-database${NORMAL} relation of current service.
  16. EXAMPLES:
  17. $exname > dump.zip
  18. $exname odoo2 > odoo2.zip
  19. "
  20. dbname=
  21. output=
  22. while [ "$1" ]; do
  23. case "$1" in
  24. "--help"|"-h")
  25. print_help >&2
  26. exit 0
  27. ;;
  28. "--force"|"-f")
  29. force=yes
  30. ;;
  31. --*|-*)
  32. err "Unexpected optional argument '$1'"
  33. print_usage >&2
  34. exit 1
  35. ;;
  36. *)
  37. [ -z "$dbname" ] && { dbname=$1 ; shift ; continue ; }
  38. err "Unexpected positional argument '$1'"
  39. print_usage >&2
  40. exit 1
  41. ;;
  42. esac
  43. shift
  44. done
  45. if [ -z "$dbname" ]; then
  46. dbname=$(relation:get "$SERVICE_NAME:postgres-database" dbname) || {
  47. err "Couldn't retrieve information of" \
  48. "${DARKYELLOW}$SERVICE_NAME${NORMAL}-->${DARKCYAN}postgres-database${NORMAL}."
  49. exit 1
  50. }
  51. fi
  52. . $CHARM_PATH/lib/common
  53. set -e
  54. odoo:save "$dbname"