ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 1 | #!/bin/bash |
dglFromAtt | 39c8bab | 2018-05-09 21:26:55 -0400 | [diff] [blame] | 2 | # |
| 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 user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 23 | |
| 24 | umask 0022 |
| 25 | TZ=GMT0 |
| 26 | COMPONENT=dmaapbc |
| 27 | APP_ROOT=/opt/app/$COMPONENT |
| 28 | USER=root |
| 29 | export TZ |
| 30 | PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin |
| 31 | export PATH |
| 32 | CLASSPATH=`echo $APP_ROOT/etc $APP_ROOT/lib/*.jar | tr ' ' ':'` |
| 33 | export CLASSPATH |
| 34 | CONTAINER_CONFIG=/opt/app/config/conf |
| 35 | MAIN=org.onap.dmaap.dbcapi.server.Main |
| 36 | |
| 37 | |
dglFromAtt | 6d9409c | 2018-04-10 00:38:14 -0400 | [diff] [blame] | 38 | |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 39 | pids() { |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 40 | set -x |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 41 | ps -ef | grep java | grep $MAIN | sed -e 's/[^ ]* *//' -e 's/ .*//' |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 42 | set +x |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | config() { |
| 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 |
dglFromAtt | 6d9409c | 2018-04-10 00:38:14 -0400 | [diff] [blame] | 59 | |
| 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 |
dglFromAtt | 038b4a4 | 2018-04-24 08:46:34 -0400 | [diff] [blame] | 67 | |
| 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 user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 76 | . misc/dmaapbc.properties.tmpl > etc/dmaapbc.properties |
| 77 | . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties |
| 78 | set +x |
| 79 | } |
| 80 | |
| 81 | start() { |
| 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 | |
dglFromAtt | 038b4a4 | 2018-04-24 08:46:34 -0400 | [diff] [blame] | 97 | if etc/havecert |
| 98 | then |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 99 | echo >/dev/null |
dglFromAtt | 038b4a4 | 2018-04-24 08:46:34 -0400 | [diff] [blame] | 100 | else |
| 101 | echo No certificate file available. Cannot start |
| 102 | exit 0 |
| 103 | fi |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 104 | 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 |
dglFromAtt | aac024c | 2018-04-10 05:33:06 -0400 | [diff] [blame] | 114 | 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" |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 115 | #nohup java $FLAGS $MAIN </dev/null >/dev/null 2>&1 & |
| 116 | nohup java $FLAGS $MAIN </dev/null & |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 117 | sleep 5 |
| 118 | PIDS=`pids` |
ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 119 | set +x |
| 120 | } |
| 121 | |
| 122 | stop() { |
| 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 | |
| 148 | status() { |
| 149 | PIDS=`pids` |
| 150 | if [ "$PIDS" != "" ] |
| 151 | then |
| 152 | echo $COMPONENT running |
| 153 | else |
| 154 | echo $COMPONENT not running |
| 155 | fi |
| 156 | } |
| 157 | |
| 158 | set -x |
| 159 | case "$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 | ;; |
| 183 | esac |
dglFromAtt | 5d2ddd5 | 2018-04-27 11:11:38 -0400 | [diff] [blame] | 184 | ls -l $APP_ROOT/logs/ONAP |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 185 | echo "------------ tail -100 error.log ---------------" |
dglFromAtt | 5d2ddd5 | 2018-04-27 11:11:38 -0400 | [diff] [blame] | 186 | tail -100 $APP_ROOT/logs/ONAP/error.log |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 187 | echo "------------ tail -100 server.log ---------------" |
dglFromAtt | 5d2ddd5 | 2018-04-27 11:11:38 -0400 | [diff] [blame] | 188 | tail -100 $APP_ROOT/logs/ONAP/server.log |
dglFromAtt | 24e3448 | 2018-03-21 08:28:10 -0400 | [diff] [blame] | 189 | echo "------------ tail -100 application.log ---------------" |
dglFromAtt | 5d2ddd5 | 2018-04-27 11:11:38 -0400 | [diff] [blame] | 190 | tail -100 $APP_ROOT/logs/ONAP/application.log |
dglFromAtt | 6d9409c | 2018-04-10 00:38:14 -0400 | [diff] [blame] | 191 | |
| 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 user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame] | 198 | exit 0 |