Mandeep Khinda | d6ea987 | 2017-06-24 11:49:37 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2015 AT&T Intellectual Properties |
| 3 | ############################################################################## |
| 4 | # Script to initialize the chef-repo branch and.chef |
| 5 | # |
| 6 | ############################################################################## |
| 7 | # Copy the certificates |
| 8 | echo 'Copying the *.crt provided in /shared folder' |
| 9 | cp --verbose /shared/*.crt /usr/local/share/ca-certificates |
| 10 | update-ca-certificates |
| 11 | |
| 12 | echo 'Running in JBOSS' |
| 13 | su - jboss |
| 14 | |
| 15 | DEBUG='' |
| 16 | if [ "$JBOSS_DEBUG" = true ] ; then |
| 17 | DEBUG="--debug" |
| 18 | fi |
| 19 | |
| 20 | #Start the chef-solo if mso-docker.json contains some data. |
| 21 | if [ -s /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json ] |
| 22 | then |
| 23 | echo "mso-docker.json has some configuration, replay the recipes." |
| 24 | chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra] |
| 25 | else |
| 26 | echo "mso-docker.json is empty, do not replay the recipes." |
| 27 | fi |
| 28 | |
| 29 | JBOSS_PIDFILE=/tmp/jboss-standalone.pid |
| 30 | $JBOSS_HOME/bin/standalone.sh ${DEBUG} -c standalone-full-ha-mso.xml & |
| 31 | JBOSS_PID=$! |
| 32 | # Trap common signals and relay them to the jboss process |
| 33 | trap "kill -HUP $JBOSS_PID" HUP |
| 34 | trap "kill -TERM $JBOSS_PID" INT |
| 35 | trap "kill -QUIT $JBOSS_PID" QUIT |
| 36 | trap "kill -PIPE $JBOSS_PID" PIPE |
| 37 | trap "kill -TERM $JBOSS_PID" TERM |
| 38 | if [ "x$JBOSS_PIDFILE" != "x" ]; then |
| 39 | echo $JBOSS_PID > $JBOSS_PIDFILE |
| 40 | fi |
| 41 | # Wait until the background process exits |
| 42 | WAIT_STATUS=128 |
| 43 | while [ "$WAIT_STATUS" -ge 128 ]; do |
| 44 | wait $JBOSS_PID 2>/dev/null |
| 45 | WAIT_STATUS=$? |
| 46 | if [ "$WAIT_STATUS" -gt 128 ]; then |
| 47 | SIGNAL=`expr $WAIT_STATUS - 128` |
| 48 | SIGNAL_NAME=`kill -l $SIGNAL` |
| 49 | echo "*** JBossAS process ($JBOSS_PID) received $SIGNAL_NAME signal ***" >&2 |
| 50 | fi |
| 51 | done |
| 52 | if [ "$WAIT_STATUS" -lt 127 ]; then |
| 53 | JBOSS_STATUS=$WAIT_STATUS |
| 54 | else |
| 55 | JBOSS_STATUS=0 |
| 56 | fi |
| 57 | if [ "$JBOSS_STATUS" -ne 10 ]; then |
| 58 | # Wait for a complete shudown |
| 59 | wait $JBOSS_PID 2>/dev/null |
| 60 | fi |
| 61 | if [ "x$JBOSS_PIDFILE" != "x" ]; then |
| 62 | grep "$JBOSS_PID" $JBOSS_PIDFILE && rm $JBOSS_PIDFILE |
| 63 | fi |