Dan Timoney | 31172d6 | 2020-06-05 15:46:39 -0400 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | ### |
| 4 | # ============LICENSE_START======================================================= |
| 5 | # ONAP : CCSDK |
| 6 | # ================================================================================ |
| 7 | # Copyright (C) 2020 AT&T Intellectual Property. All rights |
| 8 | # reserved. |
| 9 | # ================================================================================ |
| 10 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 | # you may not use this file except in compliance with the License. |
| 12 | # You may obtain a copy of the License at |
| 13 | # |
| 14 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | # |
| 16 | # Unless required by applicable law or agreed to in writing, software |
| 17 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | # See the License for the specific language governing permissions and |
| 20 | # limitations under the License. |
| 21 | # ============LICENSE_END========================================================= |
| 22 | ### |
| 23 | |
| 24 | export CCSDK_HOME=${CCSDK_HOME:-/opt/onap/ccsdk} |
| 25 | export SLIBOOT_JAR=${SLIBOOT_JAR:-@ccsdk.sliboot.jar@} |
| 26 | export SVCLOGIC_DIR=${SVCLOGIC_DIR:-opt/onap/ccsdk/svclogic/graphs} |
| 27 | export LOG_PATH=${LOG_PATH:-/var/log/onap/ccsdk} |
| 28 | export CCSDK_CONFIG_DIR=${CCSDK_CONFIG_DIR:-/opt/onap/ccsdk/config} |
| 29 | export JAVA_SECURITY_DIR=${JAVA_SECURITY_DIR:-/etc/ssl/certs/java} |
| 30 | export MYSQL_DB_HOST=${MYSQL_DB_HOST:-dbhost} |
| 31 | |
| 32 | # |
| 33 | # Wait for database |
| 34 | # |
| 35 | echo "Waiting for database" |
| 36 | until mysqladmin ping -h ${MYSQL_DB_HOST} --silent |
| 37 | do |
| 38 | printf "." |
| 39 | sleep 1 |
| 40 | done |
| 41 | echo -e "\nDatabase ready" |
| 42 | |
| 43 | # Create tablespace and user account |
| 44 | |
| 45 | mysql -h ${MYSQL_DB_HOST} -u root -p${MYSQL_ROOT_PASSWORD} mysql <<-END |
| 46 | CREATE DATABASE ${MYSQL_DB_DATABASE}; |
| 47 | CREATE USER '${MYSQL_DB_USER}'@'localhost' IDENTIFIED BY '${MYSQL_DB_PASSWD}'; |
| 48 | CREATE USER '${MYSQL_DB_USER}'@'%' IDENTIFIED BY '${MYSQL_DB_PASSWD}'; |
| 49 | GRANT ALL PRIVILEGES ON ${MYSQL_DB_DATABASE}.* TO '${MYSQL_DB_USER}'@'localhost' WITH GRANT OPTION; |
| 50 | GRANT ALL PRIVILEGES ON ${MYSQL_DB_DATABASE}.* TO '${MYSQL_DB_USER}'@'%' WITH GRANT OPTION; |
| 51 | commit; |
| 52 | END |
| 53 | |
| 54 | # Initialize schema |
| 55 | mysql -h ${MYSQL_DB_HOST} -u ${MYSQL_DB_USER} -p${MYSQL_DB_PASSWD} ${MYSQL_DB_DATABASE} < ${CCSDK_HOME}/config/schema.sql |
| 56 | |
| 57 | |
| 58 | echo -e "\nCerts ready" |
| 59 | |
| 60 | cd $CCSDK_HOME |
| 61 | java -DserviceLogicDirectory=${SVCLOGIC_DIR} -DLOG_PATH=${LOG_PATH} -jar ${CCSDK_HOME}/lib/${SLIBOOT_JAR} |
| 62 | |