Browse Source

chg: database password file can now be stored in a different directory than host !api

``DB_PASSFILE`` is split into ``HOST_DB_PASSFILE`` and ``CLIENT_DB_PASSFILE`` to allow
to use a ``HOST_DB_PASSFILE`` in a directory that is accessible to ``compose`` even when
run in docker mode.

Using this, we can store HOST_DB_PASSFILE along with the database files,
which makes a lot more sense as it resolv issues of synchronising the
database with the content of this file (namely, the authorization
scheme). So when restoring the datastore of the database, the charm
scripts will be able to use the db password file and will not have to
worry about if it is in sync with the files or not.

Note that ``db_docker_opts`` and ``db_cmd_opts`` are now bash arrays. As
previous implementation was brittle, especially for handling spaces in
arguments.
test
Valentin Lab 6 years ago
parent
commit
5d3a3fde83
  1. 20
      bin/compose-core

20
bin/compose-core

@ -560,10 +560,6 @@ ensure_db_docker_running () {
fi fi
docker_opts= docker_opts=
if [ -f "$DB_PASSFILE" ]; then
verb "Found and using '$DB_PASSFILE'."
docker_opts="$db_docker_opts -v $SERVER_ROOT_PREFIX$DB_PASSFILE:$DB_PASSFILE"
fi
debug docker network create "$_DB_NAME" debug docker network create "$_DB_NAME"
if ! network_id=$(docker network create "$_DB_NAME"); then if ! network_id=$(docker network create "$_DB_NAME"); then
err "'docker network create' failed !" err "'docker network create' failed !"
@ -619,18 +615,20 @@ _dcmd() {
debug "Db> $command $@" debug "Db> $command $@"
if [ -f "$DB_PASSFILE" ]; then
verb "Found and using '$DB_PASSFILE'."
db_docker_opts="$db_docker_opts -v $SERVER_ROOT_PREFIX$DB_PASSFILE:$DB_PASSFILE"
if [ -f "$HOST_DB_PASSFILE" -a "$CLIENT_DB_PASSFILE" ]; then
verb "Found and using '$HOST_DB_PASSFILE' as '$CLIENT_DB_PASSFILE'."
docker_opts=("${db_docker_opts[@]}" "-v" "$HOST_DB_PASSFILE:$CLIENT_DB_PASSFILE")
else
docker_opts=("${db_docker_opts[@]}")
fi fi
## XXXX was here: actualy, we need only connection between this version and the client version ## XXXX was here: actualy, we need only connection between this version and the client version
debug docker run -i --rm \ debug docker run -i --rm \
$db_docker_opts \
--entrypoint "$command" "$DOCKER_BASE_IMAGE" $db_cmd_opts "$@"
"${docker_opts[@]}" \
--entrypoint "$command" "$DOCKER_BASE_IMAGE" "${db_cmd_opts[@]}" "$@"
docker run -i --rm \ docker run -i --rm \
$db_docker_opts \
--entrypoint "$command" "$DOCKER_BASE_IMAGE" $db_cmd_opts "$@"
"${docker_opts[@]}" \
--entrypoint "$command" "$DOCKER_BASE_IMAGE" "${db_cmd_opts[@]}" "$@"
} }
export -f _dcmd export -f _dcmd

Loading…
Cancel
Save