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.

61 lines
1.2 KiB

  1. #!/bin/bash
  2. ## deploy-files will deploy data files to $DOMAIN data from given FILE/DIRECTORY/URL
  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 DBNAME"
  10. SRC=
  11. DOMAIN=
  12. while [ "$1" ]; do
  13. case "$1" in
  14. "--help"|"-h")
  15. print_usage
  16. exit 0
  17. ;;
  18. *)
  19. [ -z "$SRC" ] && { SRC=$1 ; shift ; continue ; }
  20. [ -z "$DOMAIN" ] && { DOMAIN=$1 ; shift ; continue ; }
  21. err "Unexpected argument '$1'."
  22. exit 1
  23. ;;
  24. esac
  25. shift
  26. done
  27. if [ -z "$SRC" ]; then
  28. err "You must provide a source file as first argument."
  29. print_usage
  30. exit 1
  31. fi
  32. if [ -z "$DOMAIN" ]; then
  33. err "You must provide a destination domain as second argument."
  34. exit 1
  35. fi
  36. . "$CHARM_PATH"/lib/common
  37. set -e
  38. DOCKER_SITE_PATH=/var/www/$DOMAIN
  39. if [ "$RELATION_BASE_CHARM" ]; then ## In a relation, we should use it then
  40. DST=$DATASTORE/$RELATION_BASE_CHARM$DOCKER_SITE_PATH
  41. else
  42. DST=${SERVICE_DATASTORE}$DOCKER_SITE_PATH
  43. fi
  44. echo rm -rf "$DST"
  45. mkdir -p "$DST"
  46. deploy_files "$SRC" "$DST"
  47. info "Deployed files from '$SRC' to '$DST'."