63e7800d5a841a396d1c7d1d1c7dfbaad962f229
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / deployment / src / main / release / bin / init_db.sh
1 #*******************************************************************************
2 # Copyright 2016, Nokia Corporation.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #*******************************************************************************
16 #!/bin/bash
17
18 cd ..
19
20 if [ -z "$1" ]
21 then
22     echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> "
23     exit 1
24 fi
25
26 if [ -z "$2" ]
27 then
28     echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> "
29     exit 1
30 fi
31
32 if [ -z "$3" ]
33 then
34     echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> "
35     exit 1
36 fi
37
38 if [ -z "$4" ]
39 then
40     echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> "
41     exit 1
42 fi
43
44 echo
45 echo "DB-INIT [vnfmdb] : START"
46
47 mysql -u$1 -p$2 -h$3 -P$4 <$(cd `dirname $0`; pwd)/db/mysql/db-schema.sql
48
49 if [ $? != 0 ] ; then
50    echo "DB-INIT [vnfm_db] : FAILED !"
51    exit 1
52 fi
53
54 echo "DB-INIT [vnfmdb] : PASSED"
55 echo
56 echo "*************************************************************"
57 echo "CAUTION: Existing vnfmdb will be cleaned before"
58 echo "initializing the schema, so please take a back-up of it"
59 echo "before executing it next time."
60 echo "*************************************************************"
61 exit 0