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