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
If your
DATABASE_PASSWORDincludes an ampersand (&), thesedcommand that puts the password into themirth.propertiesfile messes up the file:The ampersand needs to be escaped. In my experimentation, this SO answer looks to offer a good solution. So that section of
entrypoint.shwould look like:Edit: A cleaner way may be to use full line replacement (
/pattern to match/c replace full line with this) like this: