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

start_script.sh failed to replace db url with _ underscore in conn string #595

Open
jgu2 opened this issue Dec 23, 2020 · 0 comments
Open

Comments

@jgu2
Copy link

jgu2 commented Dec 23, 2020

Source:

echo ${DB_HOST}
if [ -z ${DB_HOST} ] ; then
    local_host=`hostname -i`
    sed "s_localhost_${local_host}_" conf/storage/db.conf.sample > conf/storage/db.conf
else
    sed "s_localhost_${DB_HOST}_" conf/storage/db.conf.sample > conf/storage/db.conf
fi

Issue:
sed failed to replace db url with _ underscore in conn string, e.g.

$ sed "s_localhost_mongodb://user_name:LADo$iu47&dlahj%a@mongodb-host.com:12345/?a=true&b=foo&c=bar" conf/storage/db.conf.sample > conf/storage/db.conf
sed: 1: "s_localhost_mongodb://f ...": bad flag in substitute command: 'n'

Potential solutions:

  1. It maybe use other delimiter that not in string with sed.
  2. use jq, e.g. jq '.timeseries.url = "mogodb://..."' conf/storage/db.conf.sample.
  3. jinja template in Python bindings - https://jinja.palletsprojects.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant