blob: 455cb834f9eed055016998cd5b853e7d836cf9ef [file] [log] [blame]
jmac065e2ce2018-03-29 01:18:02 +00001#!/bin/bash
2
3###
4# ============LICENSE_START=======================================================
5# ONAP : SDN-C
6# ================================================================================
7# Copyright (C) 2017 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
24SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040025ETC_DIR=${ETC_DIR:-${SDNC_HOME}/data}
26BIN_DIR=${BIN_DIR-${SDNC_HOME}/bin}
27MYSQL_HOST=${MYSQL_HOST:-dbhost}
28MYSQL_PASSWORD=${MYSQL_PASSWORD:-openECOMP1.0}
jmac065e2ce2018-03-29 01:18:02 +000029
30SDNC_DB_USER=${SDNC_DB_USER:-sdnctl}
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040031SDNC_DB_PASSWORD=${SDNC_DB_PASSWORD:-gamma}
jmac065e2ce2018-03-29 01:18:02 +000032SDNC_DB_DATABASE=${SDN_DB_DATABASE:-sdnctl}
33
34
35# Create tablespace and user account
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040036mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} mysql <<-END
37CREATE DATABASE IF NOT EXISTS ${SDNC_DB_DATABASE};
38CREATE USER '${SDNC_DB_USER}'@'localhost' IDENTIFIED BY '${SDNC_DB_PASSWORD}';
39CREATE USER '${SDNC_DB_USER}'@'%' IDENTIFIED BY '${SDNC_DB_PASSWORD}';
jmac065e2ce2018-03-29 01:18:02 +000040GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'localhost' WITH GRANT OPTION;
41GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'%' WITH GRANT OPTION;
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040042flush privileges;
jmac065e2ce2018-03-29 01:18:02 +000043commit;
44END
45
46# load schema
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040047if [ -f ${ETC_DIR}/sdnctl.dump ]
jmac065e2ce2018-03-29 01:18:02 +000048then
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040049 mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} sdnctl < ${ETC_DIR}/sdnctl.dump
jmac065e2ce2018-03-29 01:18:02 +000050fi
51
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040052for datafile in ${ETC_DIR}/*.data.dump
jmac065e2ce2018-03-29 01:18:02 +000053do
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040054 mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} sdnctl < $datafile
jmac065e2ce2018-03-29 01:18:02 +000055done
56
57# Create VNIs 100-199
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040058${BIN_DIR}/addVnis.sh 100 199
jmac68540b72018-05-30 19:29:04 +000059
60# Drop FK_NETWORK_MODEL foreign key as workaround for SDNC-291.
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040061${BIN_DIR}/rmForeignKey.sh NETWORK_MODEL FK_NETWORK_MODEL
62
63if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
64then
65 echo "Installing directed graphs"
66 ${SDNC_HOME}/svclogic/bin/install.sh
67fi
68
69
70exit 0