Fix Broken Docker Builds
[music.git] / music-rest / distribution / music / startup.sh
1 #!/bin/bash
2 #
3 # ============LICENSE_START==========================================
4 # org.onap.music
5 # ===================================================================
6 #  Copyright (c) 2019 AT&T Intellectual Property
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 #
20 # ============LICENSE_END=============================================
21 # ====================================================================
22
23 echo "Running startup script to get password from certman"
24 PWFILE=/opt/app/aafcertman/.password
25 LOGFILE=/opt/app/music/logs/MUSIC/music-sb.log
26 PROPS=/opt/app/music/etc/music-sb.properties
27 LOGBACK=/opt/app/music/etc/logback.xml
28 LOGGING=
29 DEBUG_PROP=
30 # Debug Setup. Uses env variables
31 # DEBUG and DEBUG_PORT
32 # DEBUG=true/false | DEBUG_PORT=<Port valie must be integer>
33 if [ "${DEBUG}" == "true" ]; then
34   if [ "${DEBUG_PORT}" == "" ]; then
35     DEBUG_PORT=8000
36   fi
37   echo "Debug mode on"
38   DEBUG_PROP="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=${DEBUG_PORT},suspend=n"
39 fi
40
41 # LOGBACK file: if /opt/app/music/etc/logback.xml exists thenuse that.
42 if [ -f $LOGBACK ]; then
43   LOGGING="--logging.config=file:${LOGBACK}"
44 fi
45
46 # Get Passwords from /opt/app/aafcertman
47 if [ -f $PWFILE ]; then
48   echo "Found ${PWFILE}" >> $LOGFILE
49   PASSWORD=$(cat ${PWFILE})
50   echo "#### Using Password from ${PWFILE} for Certs" >> ${LOGFILE}
51 else
52   PASSWORD=changeit
53   echo "#### Using Default Password for Certs" >> ${LOGFILE}
54 fi
55
56 # If music-sb.properties exists in /opt/app/music/etc then use that to override the application.properties
57 if [ -f $PROPS ]; then
58   # Run with different Property file
59   #echo "java ${DEBUG_PROP} -jar MUSIC.jar --spring.config.location=file:${PROPS} ${LOGGING} 2>&1 | tee ${LOGFILE}"
60   java ${DEBUG_PROP} -jar MUSIC-SB.jar --spring.config.location=file:${PROPS} ${LOGGING} 2>&1 | tee ${LOGFILE}
61 else
62   #echo "java ${DEBUG_PROP} -jar MUSIC.jar --server.ssl.key-store-password=${PASSWORD} ${LOGGING} 2>&1 | tee ${LOGFILE}"
63   java ${DEBUG_PROP} -jar MUSIC-SB.jar --server.ssl.key-store-password="${PASSWORD}" ${LOGGING} 2>&1 | tee ${LOGFILE}
64 fi
65
66
67
68