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