blob: c65a74b0e9a8469ad8ad56449cacb01225097b0e [file] [log] [blame]
ATT default cloud user17b1b972017-08-31 21:34:47 +00001#!/bin/bash
dglFromAtt39c8bab2018-05-09 21:26:55 -04002#
3# ============LICENSE_START==========================================
4# org.onap.dmaap
5# ===================================================================
6# Copyright © 2018 AT&T Intellectual Property. All rights reserved.
7# ===================================================================
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19# ============LICENSE_END============================================
20# ECOMP is a trademark and service mark of AT&T Intellectual Property.
21#
22#
ATT default cloud user17b1b972017-08-31 21:34:47 +000023
24umask 0022
25TZ=GMT0
26COMPONENT=dmaapbc
27APP_ROOT=/opt/app/$COMPONENT
28USER=root
29export TZ
30PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin
31export PATH
32CLASSPATH=`echo $APP_ROOT/etc $APP_ROOT/lib/*.jar | tr ' ' ':'`
33export CLASSPATH
34CONTAINER_CONFIG=/opt/app/config/conf
35MAIN=org.onap.dmaap.dbcapi.server.Main
36
37
dglFromAtt6d9409c2018-04-10 00:38:14 -040038
ATT default cloud user17b1b972017-08-31 21:34:47 +000039pids() {
dglFromAtt24e34482018-03-21 08:28:10 -040040 set -x
ATT default cloud user17b1b972017-08-31 21:34:47 +000041 ps -ef | grep java | grep $MAIN | sed -e 's/[^ ]* *//' -e 's/ .*//'
dglFromAtt24e34482018-03-21 08:28:10 -040042 set +x
ATT default cloud user17b1b972017-08-31 21:34:47 +000043}
44
45config() {
46 set -x
47 if [ ! -d $APP_ROOT ]
48 then
49 echo "Expected app root directory $APP_ROOT does not exist"
50 exit 1
51 fi
52 if [ ! -f $CONTAINER_CONFIG ]
53 then
54 echo "Expected env file $CONTAINER_CONFIG not found"
55 exit 1
56 fi
57 cd $APP_ROOT
58 source $CONTAINER_CONFIG
dglFromAtt6d9409c2018-04-10 00:38:14 -040059
60 if [ "$DMAAPBC_WAIT_TO_EXIT" != "Y" ]
61 then
62 echo "Creating $APP_ROOT/ok_to_exit so no waiting..."
63 > $APP_ROOT/ok_to_exit
64 else
65 echo "Not creating $APP_ROOT/ok_to_exit"
66 fi
dglFromAtt038b4a42018-04-24 08:46:34 -040067
68 if [ ! -f $APP_ROOT/misc/cert-client-init.sh ]
69 then
70 echo "Did not find $APP_ROOT/misc/cert-client-init.sh to append to truststore"
71 exit 1
72 fi
73 $APP_ROOT/misc/cert-client-init.sh
74 . misc/havecert.tmpl > etc/havecert
75 chmod +x etc/havecert
ATT default cloud user17b1b972017-08-31 21:34:47 +000076 . misc/dmaapbc.properties.tmpl > etc/dmaapbc.properties
77 . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties
78 set +x
79}
80
81start() {
82 set -x
83 ID=`id -n -u`
84 GRP=`id -n -g`
85 if [ "$ID" != "$USER" ]
86 then
87 echo $COMPONENT must be started as user $USER not $ID
88 exit 1
89 fi
90 if [ "$GRP" != "$USER" ]
91 then
92 echo $COMPONENT must be started as group $USER not $GRP
93 exit 1
94 fi
95 cd $APP_ROOT
96
dglFromAtt038b4a42018-04-24 08:46:34 -040097 if etc/havecert
98 then
ATT default cloud user17b1b972017-08-31 21:34:47 +000099 echo >/dev/null
dglFromAtt038b4a42018-04-24 08:46:34 -0400100 else
101 echo No certificate file available. Cannot start
102 exit 0
103 fi
ATT default cloud user17b1b972017-08-31 21:34:47 +0000104 PIDS=`pids`
105 if [ "$PIDS" != "" ]
106 then
107 echo $COMPONENT already running
108 exit 0
109 fi
110 rm -f $APP_ROOT/etc/SHUTDOWN
111
112 # JVM flags
113#old line from Dockerfile...keep for reference only
dglFromAttaac024c2018-04-10 05:33:06 -0400114 FLAGS="-cp etc:lib/* -Dlog4j.configuration=etc/log4j.properties -Ddmaapbc.properties=etc/dmaapbc.properties -Dlogback.configurationFile=etc/logback.xml -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
dglFromAtt24e34482018-03-21 08:28:10 -0400115 #nohup java $FLAGS $MAIN </dev/null >/dev/null 2>&1 &
116 nohup java $FLAGS $MAIN </dev/null &
ATT default cloud user17b1b972017-08-31 21:34:47 +0000117 sleep 5
118 PIDS=`pids`
ATT default cloud user17b1b972017-08-31 21:34:47 +0000119 set +x
120}
121
122stop() {
123 ID=`id -n -u`
124 GRP=`id -n -g`
125 if [ "$ID" != "$USER" ]
126 then
127 echo $COMPONENT must be stopped as user $USER not $ID
128 exit 1
129 fi
130 if [ "$GRP" != "$USER" ]
131 then
132 echo $COMPONENT must be stopped as group $USER not $GRP
133 exit 1
134 fi
135 touch $APP_ROOT/etc/SHUTDOWN
136 PIDS=`pids`
137 if [ "$PIDS" != "" ]
138 then
139 sleep 5
140 kill -9 $PIDS
141 sleep 5
142 echo $COMPONENT stopped
143 else
144 echo $COMPONENT not running
145 fi
146}
147
148status() {
149 PIDS=`pids`
150 if [ "$PIDS" != "" ]
151 then
152 echo $COMPONENT running
153 else
154 echo $COMPONENT not running
155 fi
156}
157
158set -x
159case "$1" in
160'deploy')
161 config
162 start
163 wait
164 ;;
165'start')
166 start
167 ;;
168'stop')
169 stop
170 ;;
171'restart')
172 stop
173 sleep 20
174 start
175 ;;
176'status')
177 status
178 ;;
179*)
180 echo "Usage: $0 { start | stop | restart }"
181 exit 1
182 ;;
183esac
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400184 ls -l $APP_ROOT/logs/ONAP
dglFromAtt24e34482018-03-21 08:28:10 -0400185 echo "------------ tail -100 error.log ---------------"
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400186 tail -100 $APP_ROOT/logs/ONAP/error.log
dglFromAtt24e34482018-03-21 08:28:10 -0400187 echo "------------ tail -100 server.log ---------------"
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400188 tail -100 $APP_ROOT/logs/ONAP/server.log
dglFromAtt24e34482018-03-21 08:28:10 -0400189 echo "------------ tail -100 application.log ---------------"
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400190 tail -100 $APP_ROOT/logs/ONAP/application.log
dglFromAtt6d9409c2018-04-10 00:38:14 -0400191
192 echo "Check $APP_ROOT/ok_to_exit"
193 while [ ! -f $APP_ROOT/ok_to_exit ]
194 do
195 echo "$APP_ROOT/ok_to_exit does not exist. Sticking around for debugging..."
196 sleep 10
197 done
ATT default cloud user17b1b972017-08-31 21:34:47 +0000198exit 0