ATT default cloud user | 17b1b97 | 2017-08-31 21:34:47 +0000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | umask 0022 |
| 4 | TZ=GMT0 |
| 5 | COMPONENT=dmaapbc |
| 6 | APP_ROOT=/opt/app/$COMPONENT |
| 7 | USER=root |
| 8 | export TZ |
| 9 | PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin |
| 10 | export PATH |
| 11 | CLASSPATH=`echo $APP_ROOT/etc $APP_ROOT/lib/*.jar | tr ' ' ':'` |
| 12 | export CLASSPATH |
| 13 | CONTAINER_CONFIG=/opt/app/config/conf |
| 14 | MAIN=org.onap.dmaap.dbcapi.server.Main |
| 15 | |
| 16 | |
| 17 | pids() { |
| 18 | #set -x |
| 19 | ps -ef | grep java | grep $MAIN | sed -e 's/[^ ]* *//' -e 's/ .*//' |
| 20 | #set +x |
| 21 | } |
| 22 | |
| 23 | config() { |
| 24 | set -x |
| 25 | if [ ! -d $APP_ROOT ] |
| 26 | then |
| 27 | echo "Expected app root directory $APP_ROOT does not exist" |
| 28 | exit 1 |
| 29 | fi |
| 30 | if [ ! -f $CONTAINER_CONFIG ] |
| 31 | then |
| 32 | echo "Expected env file $CONTAINER_CONFIG not found" |
| 33 | exit 1 |
| 34 | fi |
| 35 | cd $APP_ROOT |
| 36 | source $CONTAINER_CONFIG |
| 37 | . misc/dmaapbc.properties.tmpl > etc/dmaapbc.properties |
| 38 | . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties |
| 39 | set +x |
| 40 | } |
| 41 | |
| 42 | start() { |
| 43 | set -x |
| 44 | ID=`id -n -u` |
| 45 | GRP=`id -n -g` |
| 46 | if [ "$ID" != "$USER" ] |
| 47 | then |
| 48 | echo $COMPONENT must be started as user $USER not $ID |
| 49 | exit 1 |
| 50 | fi |
| 51 | if [ "$GRP" != "$USER" ] |
| 52 | then |
| 53 | echo $COMPONENT must be started as group $USER not $GRP |
| 54 | exit 1 |
| 55 | fi |
| 56 | cd $APP_ROOT |
| 57 | |
| 58 | # disable until we use certs |
| 59 | # if etc/havecert |
| 60 | # then |
| 61 | echo >/dev/null |
| 62 | # else |
| 63 | # echo No certificate file available. Cannot start |
| 64 | # exit 0 |
| 65 | # fi |
| 66 | PIDS=`pids` |
| 67 | if [ "$PIDS" != "" ] |
| 68 | then |
| 69 | echo $COMPONENT already running |
| 70 | exit 0 |
| 71 | fi |
| 72 | rm -f $APP_ROOT/etc/SHUTDOWN |
| 73 | |
| 74 | # JVM flags |
| 75 | #old line from Dockerfile...keep for reference only |
| 76 | FLAGS="-cp etc:lib/* -Dlog4j.configuration=etc/log4j.properties -Ddmaapbc.properties=etc/dmaapbc.properties -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" |
| 77 | nohup java $FLAGS $MAIN </dev/null >/dev/null 2>&1 & |
| 78 | sleep 5 |
| 79 | PIDS=`pids` |
| 80 | if [ "$PIDS" = "" ] |
| 81 | then |
| 82 | echo $COMPONENT startup failed |
| 83 | tail -100 $APP_ROOT/logs/dmaap*.log |
| 84 | else |
| 85 | echo $COMPONENT started |
| 86 | fi |
| 87 | set +x |
| 88 | } |
| 89 | |
| 90 | stop() { |
| 91 | ID=`id -n -u` |
| 92 | GRP=`id -n -g` |
| 93 | if [ "$ID" != "$USER" ] |
| 94 | then |
| 95 | echo $COMPONENT must be stopped as user $USER not $ID |
| 96 | exit 1 |
| 97 | fi |
| 98 | if [ "$GRP" != "$USER" ] |
| 99 | then |
| 100 | echo $COMPONENT must be stopped as group $USER not $GRP |
| 101 | exit 1 |
| 102 | fi |
| 103 | touch $APP_ROOT/etc/SHUTDOWN |
| 104 | PIDS=`pids` |
| 105 | if [ "$PIDS" != "" ] |
| 106 | then |
| 107 | sleep 5 |
| 108 | kill -9 $PIDS |
| 109 | sleep 5 |
| 110 | echo $COMPONENT stopped |
| 111 | else |
| 112 | echo $COMPONENT not running |
| 113 | fi |
| 114 | } |
| 115 | |
| 116 | status() { |
| 117 | PIDS=`pids` |
| 118 | if [ "$PIDS" != "" ] |
| 119 | then |
| 120 | echo $COMPONENT running |
| 121 | else |
| 122 | echo $COMPONENT not running |
| 123 | fi |
| 124 | } |
| 125 | |
| 126 | set -x |
| 127 | case "$1" in |
| 128 | 'deploy') |
| 129 | config |
| 130 | start |
| 131 | wait |
| 132 | ;; |
| 133 | 'start') |
| 134 | start |
| 135 | ;; |
| 136 | 'stop') |
| 137 | stop |
| 138 | ;; |
| 139 | 'restart') |
| 140 | stop |
| 141 | sleep 20 |
| 142 | start |
| 143 | ;; |
| 144 | 'status') |
| 145 | status |
| 146 | ;; |
| 147 | *) |
| 148 | echo "Usage: $0 { start | stop | restart }" |
| 149 | exit 1 |
| 150 | ;; |
| 151 | esac |
| 152 | exit 0 |