-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart
More file actions
66 lines (56 loc) · 1.94 KB
/
Copy pathstart
File metadata and controls
66 lines (56 loc) · 1.94 KB
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
#!/bin/bash
DATADIR="/var/lib/postgres/data"
CONF="/var/lib/postgres/data/postgresql.conf"
POSTGRES="/usr/lib/postgresql/9.3/bin/postgres"
INITDB="/usr/lib/postgresql/9.3/bin/initdb"
USERNAME=docker
PASSWORD=docker
# test if DATADIR is existent
if [ ! -d $DATADIR ]; then
echo "Creating Postgres data at $DATADIR"
mkdir -p $DATADIR
fi
# test if DATADIR has content
if [ ! "$(ls -A $DATADIR)" ]; then
echo "Initializing Postgres Database at $DATADIR"
chown -R postgres $DATADIR
su postgres sh -c "$INITDB --locale en_US.UTF-8 -E UTF8 -D $DATADIR"
su postgres sh -c "$POSTGRES --single -D $DATADIR -c config_file=$CONF" <<< "CREATE USER $USERNAME WITH SUPERUSER PASSWORD '$PASS';"
su postgres sh -c "$POSTGRES --single -D $DATADIR -c config_file=$CONF" <<< "CREATE DATABASE $USERNAME OWNER $USERNAME;"
# cp /data/postgres/pg_hba.conf $DATADIR/
# cp /data/postgres/postgresql.conf $DATADIR/postgresql.conf
chown -R postgres:postgres $DATADIR
cat << EOF > /opt/json-to-xls/build/install/json-to-xls/json-to-xls.yml
apiDetailsFile: api.txt
database:
driverClass: org.postgresql.Driver
user: $USERNAME
password: $PASSWORD
url: jdbc:postgresql://localhost/$USERNAME/
properties:
charSet: UTF-8
maxWaitForConnection: 5s
validationQuery: "/* MyService Health Check */ SELECT 1"
minSize: 8
maxSize: 32
checkConnectionWhileIdle: false
checkConnectionHealthWhenIdleFor: 10s
closeConnectionIfIdleFor: 1 minute
logging:
console:
enabled: true
threshold: ALL
file:
enabled: true
threshold: ALL
currentLogFilename: ./logs/json_to_xls.log
archivedLogFilenamePattern: ./logs/json_to_xls_%d.log.gz
archivedFileCount: 10
timeZone: IST
EOF
fi
trap "echo \"Sending SIGTERM to postgres\"; killall -s SIGTERM postgres" SIGTERM
su postgres sh -c "$POSTGRES -D $DATADIR -c config_file=$CONF" &
cd /opt/json-to-xls/build/install/json-to-xls/
bin/json-to-xls db migrate json-to-xls.yml
bin/json-to-xls server json-to-xls.yml