Valter Henrique Valter Henrique - 6 months ago 16
Bash Question

Why isn't my sed operation working?

I'm provisioning a

virtual machin
e with
Vagrant
.
This is my Vagrant output, debug mode, for my
Shell
script:

==> mom1: + enable_https
==> mom1: ++ cat /etc/letsencrypt/live/mom.anevis.solutions/.kpass
==> mom1: + local password=kvnilcFqq+sXmLlonoK1dM=
==> mom1: + sed -i 's,<property name="keyStorePassword" value="password" />,<property name="keyStorePassword" value="kvnilcFqq+sXmLlonoK1dM=" />,' /opt/activemq/conf/jetty.xml


It seems to be working fine, but when I check the file that was supposedly to be modified, it is empty!

<property name="keyStorePassword" value="" />


This is my Shell script:

enable_https(){
local kpass=$(cat /etc/letsencrypt/live/company.com/.kpass)
sed -i "s,<property name=\"keyStorePassword\" value=\"password\" />,<property name=\"keyStorePassword\" value=\"${kpass}\" />," /opt/activemq/conf/jetty.xml
}


The funny thing is that, when I try the same script locally, it works, but not when I try to use it during provision with Vagrant.

Any suggestion ? :)

Answer

Just for further reference, my problem was that the same file which my sed was being applied, it was modified before, by another script. Which it means, my sed was correct, indeed. However it wasn't possible to apply it over the file, since this one wasn't the same anymore.

Comments