Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 1 | #!/bin/sh |
Blackwell, Ian (ib733q) | 7b1f813 | 2018-04-03 17:28:44 +0100 | [diff] [blame] | 2 | #******************************************************************************* |
| 3 | # ============LICENSE_START========================================== |
| 4 | # org.onap.aai |
| 5 | # =================================================================== |
| 6 | # Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 7 | # Copyright © 2017-2018 European Software Marketing Ltd. |
Blackwell, Ian (ib733q) | 7b1f813 | 2018-04-03 17:28:44 +0100 | [diff] [blame] | 8 | # =================================================================== |
| 9 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | # you may not use this file except in compliance with the License. |
| 11 | # You may obtain a copy of the License at |
| 12 | # |
| 13 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | # |
| 15 | # Unless required by applicable law or agreed to in writing, software |
| 16 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | # See the License for the specific language governing permissions and |
| 19 | # limitations under the License. |
| 20 | # ============LICENSE_END============================================ |
| 21 | #******************************************************************************* |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 22 | |
Dmitry Puzikov | 89d3d25 | 2019-04-16 16:52:05 +0200 | [diff] [blame] | 23 | # jre-alpine image has $JAVA_HOME set and added to $PATH |
| 24 | # ubuntu image requires to set $JAVA_HOME and add java to $PATH manually |
| 25 | if ( uname -v | grep -i "ubuntu" ); then |
| 26 | export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-`dpkg --print-architecture | awk -F- '{ print $NF }'` |
| 27 | export PATH=${JAVA_HOME}:$PATH |
| 28 | fi |
| 29 | |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 30 | # AJSC_HOME is required for EELF logging. |
| 31 | # This path is referenced in the file logback.xml. |
| 32 | AJSC_HOME="${AJSC_HOME-/opt/app/model-loader}" |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 33 | |
| 34 | if [ -z "$CONFIG_HOME" ]; then |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 35 | echo "CONFIG_HOME must be set in order to start up the process" |
| 36 | echo "The expected value is a folder containing the model-loader.properties file" |
| 37 | exit 1 |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 38 | fi |
| 39 | |
rajeevme | fc49a34 | 2019-09-11 00:18:03 +0530 | [diff] [blame] | 40 | # Changes related to:AAI-2178 |
| 41 | # Change aai model-loader container processes to run as non-root on the host |
| 42 | USER_ID=${LOCAL_USER_ID:-9001} |
| 43 | GROUP_ID=${LOCAL_GROUP_ID:-9001} |
| 44 | ML_LOGS=/var/log/onap/AAI-ML |
| 45 | |
| 46 | if [ $(cat /etc/passwd | grep aaiadmin | wc -l) -eq 0 ]; then |
| 47 | |
| 48 | groupadd aaiadmin -g ${GROUP_ID} || { |
| 49 | echo "Unable to create the group id for ${GROUP_ID}"; |
| 50 | exit 1; |
| 51 | } |
| 52 | useradd --shell=/bin/bash -u ${USER_ID} -g ${GROUP_ID} -o -c "" -m aaiadmin || { |
| 53 | echo "Unable to create the user id for ${USER_ID}"; |
| 54 | exit 1; |
| 55 | } |
| 56 | fi; |
| 57 | chown -R aaiadmin:aaiadmin ${MICRO_HOME} |
| 58 | chown -R aaiadmin:aaiadmin ${AJSC_HOME} |
| 59 | chown -R aaiadmin:aaiadmin ${ML_LOGS} |
| 60 | find ${MICRO_HOME} -name "*.sh" -exec chmod +x {} + |
| 61 | |
| 62 | gosu aaiadmin ln -s /logs $MICRO_HOME/logs |
| 63 | JAVA_CMD="exec gosu aaiadmin java"; |
| 64 | ### |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 65 | # Some properties are repeated here for debugging purposes. |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 66 | PROPS="-DAJSC_HOME=$AJSC_HOME" |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 67 | PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME" |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 68 | PROPS="$PROPS -Dcom.att.eelf.logging.path=$AJSC_HOME" |
| 69 | PROPS="$PROPS -Dcom.att.eelf.logging.file=logback.xml" |
| 70 | PROPS="$PROPS -Dlogback.configurationFile=$AJSC_HOME/logback.xml" |
| 71 | PROPS="$PROPS -Dserver.port=9500" |
abatos | 0cecd0b | 2017-06-09 09:36:30 -0400 | [diff] [blame] | 72 | JVM_MAX_HEAP=${MAX_HEAP:-1024} |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 73 | |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 74 | if [ -z "${java_runtime_arguments}" ]; then |
| 75 | java_runtime_arguments="-Xms75m -Xmx${JVM_MAX_HEAP}m \ |
| 76 | -Dcom.sun.management.jmxremote \ |
| 77 | -Dcom.sun.management.jmxremote.authenticate=false \ |
| 78 | -Dcom.sun.management.jmxremote.ssl=false \ |
| 79 | -Dcom.sun.management.jmxremote.local.only=false \ |
| 80 | -Dcom.sun.management.jmxremote.port=1099 \ |
| 81 | -Dcom.sun.management.jmxremote.rmi.port=1099 \ |
| 82 | -Djava.rmi.server.hostname=127.0.0.1" |
| 83 | fi |
Blimkie, Steven (sb787e) | 9d2e583 | 2017-05-17 17:45:08 +0300 | [diff] [blame] | 84 | |
Dmitry Puzikov | 89d3d25 | 2019-04-16 16:52:05 +0200 | [diff] [blame] | 85 | JARFILE=$(ls ./model-loader*.jar); |
| 86 | |
mark.j.leonard | 6e4f04a | 2018-04-26 16:53:12 +0100 | [diff] [blame] | 87 | echo "java $java_runtime_arguments $PROPS -jar $JARFILE" |
rajeevme | fc49a34 | 2019-09-11 00:18:03 +0530 | [diff] [blame] | 88 | ${JAVA_CMD} $java_runtime_arguments $PROPS -jar $JARFILE |