blob: 3280253743d437acd5f76aa0f3e67fe5d03e033d [file] [log] [blame]
Mandeep Khindad6ea9872017-06-24 11:49:37 -04001#!/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
8echo 'Copying the *.crt provided in /shared folder'
9cp --verbose /shared/*.crt /usr/local/share/ca-certificates
10update-ca-certificates
11
12echo 'Running in JBOSS'
13su - jboss
14
15DEBUG=''
16if [ "$JBOSS_DEBUG" = true ] ; then
17 DEBUG="--debug"
18fi
19
20#Start the chef-solo if mso-docker.json contains some data.
21if [ -s /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json ]
22then
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]
25else
26 echo "mso-docker.json is empty, do not replay the recipes."
27fi
28
29JBOSS_PIDFILE=/tmp/jboss-standalone.pid
30$JBOSS_HOME/bin/standalone.sh ${DEBUG} -c standalone-full-ha-mso.xml &
31JBOSS_PID=$!
32# Trap common signals and relay them to the jboss process
33trap "kill -HUP $JBOSS_PID" HUP
34trap "kill -TERM $JBOSS_PID" INT
35trap "kill -QUIT $JBOSS_PID" QUIT
36trap "kill -PIPE $JBOSS_PID" PIPE
37trap "kill -TERM $JBOSS_PID" TERM
38if [ "x$JBOSS_PIDFILE" != "x" ]; then
39 echo $JBOSS_PID > $JBOSS_PIDFILE
40fi
41# Wait until the background process exits
42WAIT_STATUS=128
43while [ "$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
51done
52if [ "$WAIT_STATUS" -lt 127 ]; then
53 JBOSS_STATUS=$WAIT_STATUS
54else
55 JBOSS_STATUS=0
56fi
57if [ "$JBOSS_STATUS" -ne 10 ]; then
58 # Wait for a complete shudown
59 wait $JBOSS_PID 2>/dev/null
60fi
61if [ "x$JBOSS_PIDFILE" != "x" ]; then
62 grep "$JBOSS_PID" $JBOSS_PIDFILE && rm $JBOSS_PIDFILE
63fi