fabric8io / fabric8

fabric8 is an open source microservices platform based on Docker, Kubernetes and Jenkins
http://fabric8.io/
1.76k stars 504 forks source link

[ssh] error in the companion replace_property_value.sh script 1.x #2415

Open paoloantinori opened 9 years ago

paoloantinori commented 9 years ago

At least one of the 'sed' invocation quietly fails during the provisioning of a remote ssh container on Linux. It can be seen setting log levels before the container creation:

set DEBUG io.fabric8
container-create-ssh --host localhost --user pantinor --password XXXX  ssh03

This is the error:

...
Setting value 60000 for key gitPushInterval in etc/io.fabric8.datastore.cfg
Setting value io.fabric8.datastore for key component.name in etc/io.fabric8.datastore.cfg
Setting value fabric for key importDir in etc/io.fabric8.datastore.cfg
Setting value file:/data/repositories/github/fuse/fabric8/fabric8/fabric/fabric8-karaf/target/fabric8-karaf-1.1.0-SNAPSHOT/etc/io.fabric8.datastore.cfg for key felix.fileinstall.filename in etc/io.fabric8.datastore.cfg
sed: -e expression #1, char 70: unknown option to `s'
Setting value io.fabric8.datastore for key service.pid in etc/io.fabric8.datastore.cfg
Setting value 8102 for key sshPort in etc/org.apache.karaf.shell.cfg
Setting value 0.0.0.0 for key sshHost in etc/org.apache.karaf.shell.cfg
...

The file that needs adjustment is probably this:

https://github.com/fabric8io/fabric8/blob/master/fabric/fabric-core/src/main/resources/io/fabric8/internal/replace_property_value.sh

I think it has to do with escaping, with the fact that we are using / as a separator.

I'd like to point to the fact that Linux sed and MacOSX sed are not completely compatible, I have seen it myself in the past.

This is a discussion around the topic but there are multiple: http://unix.stackexchange.com/questions/13711/differences-between-sed-on-mac-osx-and-other-standard-sed

I wonder if it could make sense doing the extra effort to move completely away from native commands, eventually using some layer that could still be expressed with the same structure, like using this lib:

https://code.google.com/p/unix4j/

davsclaus commented 9 years ago

+1 we would like to have java code for the unzip/untar and any file modification works to set file permissions, delete dirs etc. so it works on all platforms. Today windows is not supported.

Also all those file search/replace and whatnot the SSH create container does would be nice if it was just java code too.