Skip to content

DATABASE_PASSWORD with ampersand breaks mirth.properties #44

Description

@jay-knight

If your DATABASE_PASSWORD includes an ampersand (&), the sed command that puts the password into the mirth.properties file messes up the file:

$ echo $DATABASE_PASSWORD
at&t
$ echo "database.password=blah" | sed "s/^database\.password\s*=\s*.*\$/database.password = ${DATABASE_PASSWORD//\//\\/}/"
database.password = atdatabase.password=blaht

The ampersand needs to be escaped. In my experimentation, this SO answer looks to offer a good solution. So that section of entrypoint.sh would look like:

if ! [ -z "${DATABASE_PASSWORD+x}" ]; then
        escaped_password=$(sed 's/[&/\]/\\&/g' <<<"$DATABASE_PASSWORD")
	sed -i "s/^database\.password\s*=\s*.*\$/database.password = ${escaped_password}/" /opt/connect/conf/mirth.properties
fi

Edit: A cleaner way may be to use full line replacement (/pattern to match/c replace full line with this) like this:

if ! [ -z "${DATABASE_PASSWORD+x}" ]; then
	sed -i "/^database\.password\s*=/c database.password = ${DATABASE_PASSWORD}" /opt/connect/conf/mirth.properties
fi

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions