blob: b4735986ee7952705eab5f1fed994383980e6bbf [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
dglFromAtt94688672018-08-30 18:09:54 +000034CONFIGMAP_ROOT=/opt/app/config
35CONTAINER_CONFIG=$CONFIGMAP_ROOT/conf
ATT default cloud user17b1b972017-08-31 21:34:47 +000036MAIN=org.onap.dmaap.dbcapi.server.Main
37
38
dglFromAtt6d9409c2018-04-10 00:38:14 -040039
ATT default cloud user17b1b972017-08-31 21:34:47 +000040pids() {
dglFromAtt24e34482018-03-21 08:28:10 -040041 set -x
ATT default cloud user17b1b972017-08-31 21:34:47 +000042 ps -ef | grep java | grep $MAIN | sed -e 's/[^ ]* *//' -e 's/ .*//'
dglFromAtt24e34482018-03-21 08:28:10 -040043 set +x
ATT default cloud user17b1b972017-08-31 21:34:47 +000044}
45
46config() {
47 set -x
48 if [ ! -d $APP_ROOT ]
49 then
50 echo "Expected app root directory $APP_ROOT does not exist"
51 exit 1
52 fi
53 if [ ! -f $CONTAINER_CONFIG ]
54 then
55 echo "Expected env file $CONTAINER_CONFIG not found"
56 exit 1
57 fi
58 cd $APP_ROOT
59 source $CONTAINER_CONFIG
dglFromAtt6d9409c2018-04-10 00:38:14 -040060
61 if [ "$DMAAPBC_WAIT_TO_EXIT" != "Y" ]
62 then
63 echo "Creating $APP_ROOT/ok_to_exit so no waiting..."
64 > $APP_ROOT/ok_to_exit
65 else
66 echo "Not creating $APP_ROOT/ok_to_exit"
67 fi
dglFromAtt038b4a42018-04-24 08:46:34 -040068
69 if [ ! -f $APP_ROOT/misc/cert-client-init.sh ]
70 then
71 echo "Did not find $APP_ROOT/misc/cert-client-init.sh to append to truststore"
72 exit 1
73 fi
74 $APP_ROOT/misc/cert-client-init.sh
75 . misc/havecert.tmpl > etc/havecert
76 chmod +x etc/havecert
ATT default cloud user17b1b972017-08-31 21:34:47 +000077 . misc/dmaapbc.properties.tmpl > etc/dmaapbc.properties
78 . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties
79 set +x
80}
81
82start() {
83 set -x
84 ID=`id -n -u`
85 GRP=`id -n -g`
86 if [ "$ID" != "$USER" ]
87 then
88 echo $COMPONENT must be started as user $USER not $ID
89 exit 1
90 fi
91 if [ "$GRP" != "$USER" ]
92 then
93 echo $COMPONENT must be started as group $USER not $GRP
94 exit 1
95 fi
96 cd $APP_ROOT
97
dglFromAtt038b4a42018-04-24 08:46:34 -040098 if etc/havecert
99 then
ATT default cloud user17b1b972017-08-31 21:34:47 +0000100 echo >/dev/null
dglFromAtt038b4a42018-04-24 08:46:34 -0400101 else
102 echo No certificate file available. Cannot start
103 exit 0
104 fi
ATT default cloud user17b1b972017-08-31 21:34:47 +0000105 PIDS=`pids`
106 if [ "$PIDS" != "" ]
107 then
108 echo $COMPONENT already running
109 exit 0
110 fi
111 rm -f $APP_ROOT/etc/SHUTDOWN
112
113 # JVM flags
114#old line from Dockerfile...keep for reference only
dglFromAttaac024c2018-04-10 05:33:06 -0400115 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 -0400116 #nohup java $FLAGS $MAIN </dev/null >/dev/null 2>&1 &
117 nohup java $FLAGS $MAIN </dev/null &
ATT default cloud user17b1b972017-08-31 21:34:47 +0000118 sleep 5
119 PIDS=`pids`
ATT default cloud user17b1b972017-08-31 21:34:47 +0000120 set +x
121}
122
123stop() {
124 ID=`id -n -u`
125 GRP=`id -n -g`
126 if [ "$ID" != "$USER" ]
127 then
128 echo $COMPONENT must be stopped as user $USER not $ID
129 exit 1
130 fi
131 if [ "$GRP" != "$USER" ]
132 then
133 echo $COMPONENT must be stopped as group $USER not $GRP
134 exit 1
135 fi
136 touch $APP_ROOT/etc/SHUTDOWN
137 PIDS=`pids`
138 if [ "$PIDS" != "" ]
139 then
140 sleep 5
141 kill -9 $PIDS
142 sleep 5
143 echo $COMPONENT stopped
144 else
145 echo $COMPONENT not running
146 fi
147}
148
149status() {
150 PIDS=`pids`
151 if [ "$PIDS" != "" ]
152 then
153 echo $COMPONENT running
154 else
155 echo $COMPONENT not running
156 fi
157}
158
dglFromAtt94688672018-08-30 18:09:54 +0000159init() {
160 if [ ! -d $CONFIGMAP_ROOT ]
161 then
162 echo $CONFIGMAP_ROOT does not exist
163 return
164 fi
165
166 cd $CONFIGMAP_ROOT
167 # order is important in this next list
168 for uri in dmaap dcaeLocations mr_clusters topics feeds
169 do
170 if [ -d ${uri} ]
171 then
172 for j in `ls ${uri}/*.json`
173 do
174 curl -v -X POST -H "Content-Type: application/json" -d @${j} http://dmaap-bc:8080/webapi/${uri}
175 done
176 fi
177 done
178}
179
ATT default cloud user17b1b972017-08-31 21:34:47 +0000180set -x
181case "$1" in
182'deploy')
183 config
184 start
dglFromAtt94688672018-08-30 18:09:54 +0000185 init
ATT default cloud user17b1b972017-08-31 21:34:47 +0000186 wait
187 ;;
188'start')
189 start
190 ;;
191'stop')
192 stop
193 ;;
194'restart')
195 stop
196 sleep 20
197 start
198 ;;
199'status')
200 status
201 ;;
202*)
203 echo "Usage: $0 { start | stop | restart }"
204 exit 1
205 ;;
206esac
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400207 ls -l $APP_ROOT/logs/ONAP
dglFromAtt24e34482018-03-21 08:28:10 -0400208 echo "------------ tail -100 error.log ---------------"
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400209 tail -100 $APP_ROOT/logs/ONAP/error.log
dglFromAtt24e34482018-03-21 08:28:10 -0400210 echo "------------ tail -100 server.log ---------------"
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400211 tail -100 $APP_ROOT/logs/ONAP/server.log
dglFromAtt24e34482018-03-21 08:28:10 -0400212 echo "------------ tail -100 application.log ---------------"
dglFromAtt5d2ddd52018-04-27 11:11:38 -0400213 tail -100 $APP_ROOT/logs/ONAP/application.log
dglFromAtt6d9409c2018-04-10 00:38:14 -0400214
215 echo "Check $APP_ROOT/ok_to_exit"
216 while [ ! -f $APP_ROOT/ok_to_exit ]
217 do
218 echo "$APP_ROOT/ok_to_exit does not exist. Sticking around for debugging..."
219 sleep 10
220 done
ATT default cloud user17b1b972017-08-31 21:34:47 +0000221exit 0