-
Notifications
You must be signed in to change notification settings - Fork 69
/
setup_postgresql.sh
executable file
·81 lines (64 loc) · 2.79 KB
/
setup_postgresql.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
if [ "$RDS_HOSTNAME" ]; then
PGHOST="$RDS_HOSTNAME"
PGUSER="$RDS_USERNAME"
PGPASSWORD="$RDS_PASSWORD"
PGDATABASE="$RDS_DB_NAME"
PGPORT="$RDS_PORT"
fi
if [ "$PGHOST" ]; then
if [ ! "$PGPORT" ]; then
PGPORT=5432
fi
if [ ! "$PGDATABASE" ]; then
PGDATABASE=postgres
fi
if [ ! "$PGUSER" ]; then
PGUSER=pgadmin
fi
if [ ! "$PGPASSWORD" ]; then
PGPASSWORD=pgadmin.
fi
export PGPASSWORD="$PGPASSWORD"
echo "Checking PostgreSQL connection ..."
nc -zv $PGHOST $PGPORT
if [ "$?" -ne "0" ]; then
echo "PostgreSQL connection failed."
exit 0
fi
CHK_QUARTZ=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep quartz | wc -l)"`
CHK_HIBERNATE=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep hibernate | wc -l)"`
CHK_JCR=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep jackrabbit | wc -l)"`
CHK_SDATA=`echo "$(psql -U $PGUSER -h $PGHOST -d $PGDATABASE -l | grep sampledata | wc -l)"`
echo "quartz: $CHK_QUARTZ"
echo "hibernate: $CHK_HIBERNATE"
echo "jcr: $CHK_JCR"
echo "sampledata: $CHK_SDATA"
cp -r $PENTAHO_HOME/config $PENTAHO_HOME/config_tmp
rm -rf "$PENTAHO_HOME/biserver-ce/tomcat/conf/Catalina/*"
rm -rf "$PENTAHO_HOME/biserver-ce/tomcat/temp/*"
rm -rf "$PENTAHO_HOME/biserver-ce/tomcat/work/*"
rm -rf "$PENTAHO_HOME/biserver-ce/tomcat/logs/*"
$PENTAHO_HOME/scripts/replace.sh "localhost:5432" "$PGHOST:$PGPORT" -path "$PENTAHO_HOME/config_tmp/" -infile
$PENTAHO_HOME/scripts/replace.sh "@@hibuser@@" "$PGPASSWORD" -path "$PENTAHO_HOME/config_tmp/" -infile
$PENTAHO_HOME/scripts/replace.sh "@@jcr_user@@" "$PGPASSWORD" -path "$PENTAHO_HOME/config_tmp/" -infile
$PENTAHO_HOME/scripts/replace.sh "@@pentaho_user@@" "$PGPASSWORD" -path "$PENTAHO_HOME/config_tmp/" -infile
$PENTAHO_HOME/scripts/replace.sh "awsbiuser" "$PGUSER" -path "$PENTAHO_HOME/config_tmp/" -infile
if [ "$RDS_HOSTNAME" ]; then
sed -i 's/TABLESPACE = pg_default;/;/g' $PENTAHO_HOME/config_tmp/postgresql/biserver-ce/data/postgresql/*.sql
fi
cp -r $PENTAHO_HOME/config_tmp/postgresql/biserver-ce/* $PENTAHO_HOME/biserver-ce/
rm -rf $PENTAHO_HOME/config_tmp
if [ "$CHK_JCR" -eq "0" ]; then
psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_HOME/biserver-ce/data/postgresql/create_jcr_postgresql.sql
fi
if [ "$CHK_HIBERNATE" -eq "0" ]; then
psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_HOME/biserver-ce/data/postgresql/create_repository_postgresql.sql
fi
if [ "$CHK_QUARTZ" -eq "0" ]; then
psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_HOME/biserver-ce/data/postgresql/create_quartz_postgresql.sql
fi
if [ "$CHK_SDATA" -eq "0" ]; then
psql -U $PGUSER -h $PGHOST -d $PGDATABASE -f $PENTAHO_HOME/biserver-ce/data/postgresql/sampledata.sql
fi
fi