blob: 2406a48c37cc77e7437552f8e6f7e1fe70d6a142 [file] [log] [blame]
Guillaume Lambert85b14922021-03-12 13:53:18 +01001#!/bin/sh
jmac065e2ce2018-03-29 01:18:02 +00002
Guillaume Lambert85b14922021-03-12 13:53:18 +01003{{/*
jmac065e2ce2018-03-29 01:18:02 +00004###
5# ============LICENSE_START=======================================================
6# ONAP : SDN-C
7# ================================================================================
guillaume.lambert7bf306e2021-09-08 12:03:22 +02008# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
jmac065e2ce2018-03-29 01:18:02 +00009# ================================================================================
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###
Jakub Latuseke0e8ca72020-10-21 13:36:29 +020023*/}}
jmac065e2ce2018-03-29 01:18:02 +000024
25SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc}
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040026ETC_DIR=${ETC_DIR:-${SDNC_HOME}/data}
27BIN_DIR=${BIN_DIR-${SDNC_HOME}/bin}
28MYSQL_HOST=${MYSQL_HOST:-dbhost}
Krzysztof Opasiakcc97c732020-02-25 23:31:20 +010029MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD}
jmac065e2ce2018-03-29 01:18:02 +000030
Krzysztof Opasiakcc97c732020-02-25 23:31:20 +010031SDNC_DB_USER=${SDNC_DB_USER}
32SDNC_DB_PASSWORD=${SDNC_DB_PASSWORD}
33SDNC_DB_DATABASE=${SDNC_DB_DATABASE}
jmac065e2ce2018-03-29 01:18:02 +000034
35
36# Create tablespace and user account
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040037mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} mysql <<-END
38CREATE DATABASE IF NOT EXISTS ${SDNC_DB_DATABASE};
andreasgeisslera72340f2021-03-17 09:49:59 +010039CREATE USER IF NOT EXISTS '${SDNC_DB_USER}'@'localhost' IDENTIFIED BY '${SDNC_DB_PASSWORD}';
40CREATE USER IF NOT EXISTS '${SDNC_DB_USER}'@'%' IDENTIFIED BY '${SDNC_DB_PASSWORD}';
jmac065e2ce2018-03-29 01:18:02 +000041GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'localhost' WITH GRANT OPTION;
42GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'%' WITH GRANT OPTION;
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040043flush privileges;
jmac065e2ce2018-03-29 01:18:02 +000044commit;
45END
46
47# load schema
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040048if [ -f ${ETC_DIR}/sdnctl.dump ]
jmac065e2ce2018-03-29 01:18:02 +000049then
Krzysztof Opasiakcc97c732020-02-25 23:31:20 +010050 mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} ${SDNC_DB_DATABASE} < ${ETC_DIR}/sdnctl.dump
jmac065e2ce2018-03-29 01:18:02 +000051fi
52
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040053for datafile in ${ETC_DIR}/*.data.dump
jmac065e2ce2018-03-29 01:18:02 +000054do
Krzysztof Opasiakcc97c732020-02-25 23:31:20 +010055 mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} ${SDNC_DB_DATABASE} < $datafile
jmac065e2ce2018-03-29 01:18:02 +000056done
57
58# Create VNIs 100-199
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040059${BIN_DIR}/addVnis.sh 100 199
jmac68540b72018-05-30 19:29:04 +000060
61# Drop FK_NETWORK_MODEL foreign key as workaround for SDNC-291.
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040062${BIN_DIR}/rmForeignKey.sh NETWORK_MODEL FK_NETWORK_MODEL
63
64if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ]
65then
66 echo "Installing directed graphs"
Sylvain Desbureaux68ea0c62020-12-15 09:43:49 +010067 ${SDNC_HOME}/svclogic/bin/install.sh
Timoney, Dan (dt5972)a3bc1a52019-06-26 16:16:52 -040068fi
69
70
71exit 0