blob: 3ca2ad6d90d2d9f87d0c3803a6274da9186c3dd0 [file] [log] [blame]
Dan Timoney31172d62020-06-05 15:46:39 -04001#!/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
24export CCSDK_HOME=${CCSDK_HOME:-/opt/onap/ccsdk}
25export SLIBOOT_JAR=${SLIBOOT_JAR:-@ccsdk.sliboot.jar@}
26export SVCLOGIC_DIR=${SVCLOGIC_DIR:-opt/onap/ccsdk/svclogic/graphs}
27export LOG_PATH=${LOG_PATH:-/var/log/onap/ccsdk}
28export CCSDK_CONFIG_DIR=${CCSDK_CONFIG_DIR:-/opt/onap/ccsdk/config}
29export JAVA_SECURITY_DIR=${JAVA_SECURITY_DIR:-/etc/ssl/certs/java}
30export MYSQL_DB_HOST=${MYSQL_DB_HOST:-dbhost}
31
32#
33# Wait for database
34#
35echo "Waiting for database"
36until mysqladmin ping -h ${MYSQL_DB_HOST} --silent
37do
38 printf "."
39 sleep 1
40done
41echo -e "\nDatabase ready"
42
43# Create tablespace and user account
44
45mysql -h ${MYSQL_DB_HOST} -u root -p${MYSQL_ROOT_PASSWORD} mysql <<-END
46CREATE DATABASE ${MYSQL_DB_DATABASE};
47CREATE USER '${MYSQL_DB_USER}'@'localhost' IDENTIFIED BY '${MYSQL_DB_PASSWD}';
48CREATE USER '${MYSQL_DB_USER}'@'%' IDENTIFIED BY '${MYSQL_DB_PASSWD}';
49GRANT ALL PRIVILEGES ON ${MYSQL_DB_DATABASE}.* TO '${MYSQL_DB_USER}'@'localhost' WITH GRANT OPTION;
50GRANT ALL PRIVILEGES ON ${MYSQL_DB_DATABASE}.* TO '${MYSQL_DB_USER}'@'%' WITH GRANT OPTION;
51commit;
52END
53
54# Initialize schema
55mysql -h ${MYSQL_DB_HOST} -u ${MYSQL_DB_USER} -p${MYSQL_DB_PASSWD} ${MYSQL_DB_DATABASE} < ${CCSDK_HOME}/config/schema.sql
56
57
58echo -e "\nCerts ready"
59
60cd $CCSDK_HOME
61java -DserviceLogicDirectory=${SVCLOGIC_DIR} -DLOG_PATH=${LOG_PATH} -jar ${CCSDK_HOME}/lib/${SLIBOOT_JAR}
62