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.

55 lines
1.1 KiB

  1. #!/bin/bash
  2. ## Load action gets a first argument a FILE/DIRECTORY/URL holding the necessary files.
  3. ##
  4. ##
  5. if [ -z "$SERVICE_DATASTORE" ]; then
  6. echo "This script is meant to be run through 'compose' to work properly." >&2
  7. exit 1
  8. fi
  9. usage="$exname [-h|--help] SOURCE"
  10. dbname=
  11. while [ "$1" ]; do
  12. case "$1" in
  13. "--help"|"-h")
  14. print_usage
  15. exit 0
  16. ;;
  17. *)
  18. [ -z "$SOURCE" ] && { SOURCE=$1 ; shift ; continue ; }
  19. err "Unexpected argument '$1'."
  20. exit 1
  21. ;;
  22. esac
  23. shift
  24. done
  25. if [ -z "$SOURCE" ]; then
  26. err "You must provide a source file as first argument."
  27. print_usage
  28. exit 1
  29. fi
  30. include parse
  31. include pretty
  32. set -e
  33. USER=$(relation-get user)
  34. DBNAME=$(relation-get dbname)
  35. POSTGIS=$(relation-get postgis 2>/dev/null) || true
  36. UNACCENT=$(relation-get unaccent 2>/dev/null) || true
  37. opts=()
  38. if [ "$POSTGIS" ]; then
  39. opts+=("--with-postgis")
  40. fi
  41. if [ "$UNACCENT" ]; then
  42. opts+=("--with-unaccent")
  43. fi
  44. run_service_action "$RELATION_TARGET_SERVICE" load "$SOURCE" "$USER@$DBNAME" "${opts[@]}" "$@"