Do not start chef-solo if mso-docker.json is empty 51/5351/3
authorAlexis de Talhouët <adetalhouet89@gmail.com>
Wed, 8 Mar 2017 15:03:14 +0000 (10:03 -0500)
committerAlexis de Talhouët <adetalhouet89@gmail.com>
Wed, 8 Mar 2017 15:03:14 +0000 (10:03 -0500)
Chef-solo is started both from the docker container [1] and from
the start-jboss-server.sh script [2].
The Dockerfile is configured to erase the mso-docker.json
configuration once applied, so when the container is started,
and the strat-jboss-server.sh tries to play the recipes again,
it fails as the environment file is empty.

This patch adds a check to see if the file is empty, if not, we
play the chef-solo recipes again, to overwrite the config.

[1]: https://gerrit.openecomp.org/r/gitweb?p=mso.git;a=blob;f=packages/docker/src/main/docker/docker-files/Dockerfile.mso-chef-final;h=ff7f44bcfdba6fa0328cbd50803d3dc80a2a1def;hb=refs/heads/master#l57
[2]: https://gerrit.openecomp.org/r/gitweb?p=mso.git;a=blob;f=packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh;h=2e9b9da27dd3d01fcf5ebc304ac03b15142fde53;hb=refs/heads/master#l16

Change-Id: I34573dedaaafbeb6b511f47b72e6e0cefea4e1d5
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 2e9b9da..d8d81cc
@@ -12,9 +12,14 @@ update-ca-certificates
 echo 'Running in JBOSS'
 su - jboss
 
-#Start the chef-solo
-chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra]
-
+#Start the chef-solo if mso-docker.json contains some data.
+if [ -s /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json ] 
+then
+       echo "mso-docker.json has some configuration, replay the recipes."
+       chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra]
+else
+       echo "mso-docker.json is empty, do not replay the recipes."
+fi
 
 JBOSS_PIDFILE=/tmp/jboss-standalone.pid
 $JBOSS_HOME/bin/standalone.sh -c standalone-full-ha-mso.xml &