Guillaume Lambert | 85b1492 | 2021-03-12 13:53:18 +0100 | [diff] [blame^] | 1 | #!/bin/sh |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 2 | |
Guillaume Lambert | 85b1492 | 2021-03-12 13:53:18 +0100 | [diff] [blame^] | 3 | {{/* |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 4 | ### |
| 5 | # ============LICENSE_START======================================================= |
| 6 | # ONAP : SDN-C |
| 7 | # ================================================================================ |
guillaume.lambert | 7bf306e | 2021-09-08 12:03:22 +0200 | [diff] [blame] | 8 | # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 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 | ### |
Jakub Latusek | e0e8ca7 | 2020-10-21 13:36:29 +0200 | [diff] [blame] | 23 | */}} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 24 | |
| 25 | SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc} |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 26 | ETC_DIR=${ETC_DIR:-${SDNC_HOME}/data} |
| 27 | BIN_DIR=${BIN_DIR-${SDNC_HOME}/bin} |
| 28 | MYSQL_HOST=${MYSQL_HOST:-dbhost} |
Krzysztof Opasiak | cc97c73 | 2020-02-25 23:31:20 +0100 | [diff] [blame] | 29 | MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 30 | |
Krzysztof Opasiak | cc97c73 | 2020-02-25 23:31:20 +0100 | [diff] [blame] | 31 | SDNC_DB_USER=${SDNC_DB_USER} |
| 32 | SDNC_DB_PASSWORD=${SDNC_DB_PASSWORD} |
| 33 | SDNC_DB_DATABASE=${SDNC_DB_DATABASE} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 34 | |
| 35 | |
| 36 | # Create tablespace and user account |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 37 | mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} mysql <<-END |
| 38 | CREATE DATABASE IF NOT EXISTS ${SDNC_DB_DATABASE}; |
andreasgeissler | a72340f | 2021-03-17 09:49:59 +0100 | [diff] [blame] | 39 | CREATE USER IF NOT EXISTS '${SDNC_DB_USER}'@'localhost' IDENTIFIED BY '${SDNC_DB_PASSWORD}'; |
| 40 | CREATE USER IF NOT EXISTS '${SDNC_DB_USER}'@'%' IDENTIFIED BY '${SDNC_DB_PASSWORD}'; |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 41 | GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'localhost' WITH GRANT OPTION; |
| 42 | GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'%' WITH GRANT OPTION; |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 43 | flush privileges; |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 44 | commit; |
| 45 | END |
| 46 | |
| 47 | # load schema |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 48 | if [ -f ${ETC_DIR}/sdnctl.dump ] |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 49 | then |
Krzysztof Opasiak | cc97c73 | 2020-02-25 23:31:20 +0100 | [diff] [blame] | 50 | mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} ${SDNC_DB_DATABASE} < ${ETC_DIR}/sdnctl.dump |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 51 | fi |
| 52 | |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 53 | for datafile in ${ETC_DIR}/*.data.dump |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 54 | do |
Krzysztof Opasiak | cc97c73 | 2020-02-25 23:31:20 +0100 | [diff] [blame] | 55 | mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} ${SDNC_DB_DATABASE} < $datafile |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 56 | done |
| 57 | |
| 58 | # Create VNIs 100-199 |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 59 | ${BIN_DIR}/addVnis.sh 100 199 |
jmac | 68540b7 | 2018-05-30 19:29:04 +0000 | [diff] [blame] | 60 | |
| 61 | # Drop FK_NETWORK_MODEL foreign key as workaround for SDNC-291. |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 62 | ${BIN_DIR}/rmForeignKey.sh NETWORK_MODEL FK_NETWORK_MODEL |
| 63 | |
| 64 | if [ -x ${SDNC_HOME}/svclogic/bin/install.sh ] |
| 65 | then |
| 66 | echo "Installing directed graphs" |
Sylvain Desbureaux | 68ea0c6 | 2020-12-15 09:43:49 +0100 | [diff] [blame] | 67 | ${SDNC_HOME}/svclogic/bin/install.sh |
Timoney, Dan (dt5972) | a3bc1a5 | 2019-06-26 16:16:52 -0400 | [diff] [blame] | 68 | fi |
| 69 | |
| 70 | |
| 71 | exit 0 |