1a38fff8992fd74255069f1f6b8dcbae9a3997c8
[so.git] / packages / docker / src / main / docker / docker-files / scripts / start-jboss-server.sh
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 --fresh
11
12 echo 'Running in JBOSS'
13 su - jboss
14
15 #Start the chef-solo if mso-docker.json contains some data.
16 if [ -s /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json ] 
17 then
18         echo "mso-docker.json has some configuration, replay the recipes."
19         chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra]
20 else
21         echo "mso-docker.json is empty, do not replay the recipes."
22 fi
23
24 JBOSS_PIDFILE=/tmp/jboss-standalone.pid
25 $JBOSS_HOME/bin/standalone.sh -c standalone-full-ha-mso.xml &
26 JBOSS_PID=$!
27 # Trap common signals and relay them to the jboss process
28 trap "kill -HUP  $JBOSS_PID" HUP
29 trap "kill -TERM $JBOSS_PID" INT
30 trap "kill -QUIT $JBOSS_PID" QUIT
31 trap "kill -PIPE $JBOSS_PID" PIPE
32 trap "kill -TERM $JBOSS_PID" TERM
33 if [ "x$JBOSS_PIDFILE" != "x" ]; then
34   echo $JBOSS_PID > $JBOSS_PIDFILE
35 fi
36 # Wait until the background process exits
37 WAIT_STATUS=128
38 while [ "$WAIT_STATUS" -ge 128 ]; do
39    wait $JBOSS_PID 2>/dev/null
40    WAIT_STATUS=$?
41    if [ "$WAIT_STATUS" -gt 128 ]; then
42       SIGNAL=`expr $WAIT_STATUS - 128`
43       SIGNAL_NAME=`kill -l $SIGNAL`
44       echo "*** JBossAS process ($JBOSS_PID) received $SIGNAL_NAME signal ***" >&2
45    fi
46 done
47 if [ "$WAIT_STATUS" -lt 127 ]; then
48    JBOSS_STATUS=$WAIT_STATUS
49 else
50    JBOSS_STATUS=0
51 fi
52 if [ "$JBOSS_STATUS" -ne 10 ]; then
53       # Wait for a complete shudown
54       wait $JBOSS_PID 2>/dev/null
55 fi
56 if [ "x$JBOSS_PIDFILE" != "x" ]; then
57       grep "$JBOSS_PID" $JBOSS_PIDFILE && rm $JBOSS_PIDFILE
58 fi