Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATABASE_PASSWORD with ampersand breaks mirth.properties #44

Open
jay-knight opened this issue Jan 19, 2024 · 0 comments
Open

DATABASE_PASSWORD with ampersand breaks mirth.properties #44

jay-knight opened this issue Jan 19, 2024 · 0 comments

Comments

@jay-knight
Copy link

jay-knight commented Jan 19, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants