jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 1 | #!/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 | |
| 24 | SDNC_HOME=${SDNC_HOME:-/opt/onap/sdnc} |
jmac | bc92d13 | 2018-04-07 03:46:12 +0000 | [diff] [blame] | 25 | MYSQL_HOST=${MYSQL_HOST:-{{.Release.Name}}-{{.Values.mysql.nameOverride}}-0.{{.Values.mysql.service.name}}.{{.Release.Namespace}}} |
| 26 | MYSQL_PASSWD=${MYSQL_PASSWD:-{{.Values.config.dbRootPassword}}} |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 27 | |
| 28 | SDNC_DB_USER=${SDNC_DB_USER:-sdnctl} |
| 29 | SDNC_DB_PASSWD=${SDNC_DB_PASSWD:-gamma} |
| 30 | SDNC_DB_DATABASE=${SDN_DB_DATABASE:-sdnctl} |
| 31 | |
| 32 | |
| 33 | # Create tablespace and user account |
jmac | bc92d13 | 2018-04-07 03:46:12 +0000 | [diff] [blame] | 34 | mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWD} mysql <<-END |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 35 | CREATE DATABASE ${SDNC_DB_DATABASE}; |
| 36 | CREATE USER '${SDNC_DB_USER}'@'localhost' IDENTIFIED BY '${SDNC_DB_PASSWD}'; |
| 37 | CREATE USER '${SDNC_DB_USER}'@'%' IDENTIFIED BY '${SDNC_DB_PASSWD}'; |
| 38 | GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'localhost' WITH GRANT OPTION; |
| 39 | GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'%' WITH GRANT OPTION; |
| 40 | commit; |
| 41 | END |
| 42 | |
| 43 | # load schema |
| 44 | if [ -f ${SDNC_HOME}/data/sdnctl.dump ] |
| 45 | then |
jmac | bc92d13 | 2018-04-07 03:46:12 +0000 | [diff] [blame] | 46 | mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWD} sdnctl < ${SDNC_HOME}/data/sdnctl.dump |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 47 | fi |
| 48 | |
| 49 | for datafile in ${SDNC_HOME}/data/*.data.dump |
| 50 | do |
jmac | bc92d13 | 2018-04-07 03:46:12 +0000 | [diff] [blame] | 51 | mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWD} sdnctl < $datafile |
jmac | 065e2ce | 2018-03-29 01:18:02 +0000 | [diff] [blame] | 52 | done |
| 53 | |
| 54 | # Create VNIs 100-199 |
| 55 | ${SDNC_HOME}/bin/addVnis.sh 100 199 |