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