feat:Modify access node display format
[usecase-ui/server.git] / standalone / src / main / assembly / resources / bin / initDB.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17
18 echo "setting database init parameters"
19 main_path="/home/uui"
20 host=$1
21 port=$2
22 user_pg=$3
23 user_uui=$4
24
25 echo "setting postgres database password"
26 #su - $user_pg <<EOF
27 psql --command "alter user $user_pg with password '$user_pg';"
28 #EOF
29
30 echo "start create usecase-ui database..."
31 dbscripts_path="$main_path/resources/dbscripts/postgres"
32 psql "host=$host port=$port user=$user_pg password=$user_pg dbname=$user_pg" -f $dbscripts_path/uui_create_db.sql
33 sql_result=$?
34 if [ $sql_result -ne 0 ]; then
35     echo "failed to create usecase-ui database!"
36     exit 1
37 else
38     echo "usecase-ui database created successfully!"
39 fi
40
41 echo "start create usecase-ui tables..."
42 psql "host=$host port=$port user=$user_uui password=$user_uui dbname=$user_uui" -f $dbscripts_path/uui_create_table.sql
43 sql_result=$?
44 if [ $sql_result -ne 0 ]; then
45     echo "failed to create usecase-ui table!"
46     exit 1
47 else
48     echo "usecase-ui tables created successfully!"
49 fi
50
51 echo "start insert initial data into uui-server database..."
52 psql "host=$host port=$port user=$user_uui password=$user_uui dbname=$user_uui" -f $dbscripts_path/uui_init_data.sql
53 sql_result=$?
54 if [ $sql_result -ne 0 ]; then
55     echo "failed to insert initial data!"
56     exit 1
57 else
58     echo "usecase-ui database initial data import succeed!"
59 fi