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