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.

50 lines
1.1 KiB

  1. #!/bin/bash
  2. ## Load action gets a first argument a DIRECTORY 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] DBNAME [MODULE ...]"
  10. dbname=
  11. modules=()
  12. while [ "$1" ]; do
  13. case "$1" in
  14. "--help"|"-h")
  15. print_usage
  16. exit 0
  17. ;;
  18. *)
  19. [ -z "$dbname" ] && { dbname=$1 ; shift ; continue ; }
  20. modules+=("$1")
  21. ;;
  22. esac
  23. shift
  24. done
  25. if [ -z "$dbname" ]; then
  26. err "You must provide a destination database name as second argument."
  27. print_usage
  28. exit 1
  29. fi
  30. if [ -z "${modules[*]}" ]; then
  31. err "You must provide at least one module as third argument."
  32. print_usage
  33. exit 1
  34. fi
  35. modules="$(echo "${modules[@]}" | tr " " ",")"
  36. ## This can work only if ~/.my.cnf is correctly created by init.
  37. set -e
  38. launch_docker_compose run "$CONTAINER_NAME" --init="$modules" -d "$dbname" --stop-after-init
  39. info "Installed '$modules' module(s) into database '$dbname'."