Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / appc / resources / config / appc / opt / onap / appc / bin / installAppcDb.sh
1 #!/bin/sh
2
3 {{/*
4 ###
5 # ============LICENSE_START=======================================================
6 # APPC
7 # ================================================================================
8 # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
9 # Modifications Copyright © 2018 Amdocs,Bell Canada
10 # ================================================================================
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14 #
15 #      http://www.apache.org/licenses/LICENSE-2.0
16 #
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22 # ============LICENSE_END=========================================================
23 ###
24 */}}
25
26 SDNC_HOME=${SDNC_HOME:-/opt/onap/ccsdk}
27 APPC_HOME=${APPC_HOME:-/opt/onap/appc}
28 MYSQL_PASSWD=${MYSQL_ROOT_PASSWORD}
29
30 APPC_DB_USER=${APPC_DB_USER}
31 APPC_DB_PASSWD=${APPC_DB_PASSWD}
32 APPC_DB_DATABASE={{.Values.config.appcdb.dbName}}
33 SDNC_DB_DATABASE={{.Values.config.sdncdb.dbName}}
34
35
36 # Create tablespace and user account
37 mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} mysql <<-END
38 CREATE DATABASE ${APPC_DB_DATABASE};
39 CREATE USER '${APPC_DB_USER}'@'localhost' IDENTIFIED BY '${APPC_DB_PASSWD}';
40 CREATE USER '${APPC_DB_USER}'@'%' IDENTIFIED BY '${APPC_DB_PASSWD}';
41 GRANT ALL PRIVILEGES ON ${APPC_DB_DATABASE}.* TO '${APPC_DB_USER}'@'localhost' WITH GRANT OPTION;
42 GRANT ALL PRIVILEGES ON ${APPC_DB_DATABASE}.* TO '${APPC_DB_USER}'@'%' WITH GRANT OPTION;
43 commit;
44 END
45
46 if [ -f ${APPC_HOME}/data/appcctl.dump ]
47 then
48   mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} ${APPC_DB_DATABASE} < ${APPC_HOME}/data/appcctl.dump
49 fi
50
51 if [ -f ${APPC_HOME}/data/sdnctl.dump ]
52 then
53   mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} ${SDNC_DB_DATABASE} < ${APPC_HOME}/data/sdnctl.dump
54 fi
55
56 if [ -f ${APPC_HOME}/data/sqlData.dump ]
57 then
58   mysql -h {{.Values.config.mariadbGaleraSVCName}}.{{.Release.Namespace}} -u root -p${MYSQL_PASSWD} ${SDNC_DB_DATABASE} < ${APPC_HOME}/data/sqlData.dump
59 fi