1
- #! /bin/bash
2
- set -e
3
-
4
- # wtf is that?
5
- if [ " ${1: 0: 1} " = ' -' ]; then
6
- set -- postgres " $@ "
7
- fi
8
-
9
- echo " /pg/%p.%s.%c.%P.core" | sudo tee /proc/sys/kernel/core_pattern
1
+ #! /bin/sh
10
2
11
3
if [ " $1 " = ' postgres' ]; then
12
4
mkdir -p " $PGDATA "
13
- chmod 700 " $PGDATA "
14
- chown -R postgres " $PGDATA "
15
5
16
6
# look specifically for PG_VERSION, as it is expected in the DB dir
17
7
if [ ! -s " $PGDATA /PG_VERSION" ]; then
18
8
initdb --nosync
19
9
20
- if [ " $POSTGRES_PASSWORD " ]; then
21
- pass=" PASSWORD '$POSTGRES_PASSWORD '"
22
- authMethod=md5
23
- else
24
- pass=
25
- authMethod=trust
26
- fi
27
-
28
- { echo ; echo " host all all 0.0.0.0/0 $authMethod " ; } >> " $PGDATA /pg_hba.conf"
29
- { echo ; echo " host replication all 0.0.0.0/0 $authMethod " ; } >> " $PGDATA /pg_hba.conf"
30
-
31
- # ###########################################################################
10
+ { echo ; echo " host all all 0.0.0.0/0 trust" ; } >> " $PGDATA /pg_hba.conf"
11
+ { echo ; echo " host replication all 0.0.0.0/0 trust" ; } >> " $PGDATA /pg_hba.conf"
32
12
33
- # internal start of server in order to allow set-up using psql-client
13
+ # internal start of server in order to allow set-up using psql-client
34
14
# does not listen on TCP/IP and waits until start finishes
35
15
pg_ctl -D " $PGDATA " \
36
16
-o " -c listen_addresses=''" \
37
17
-w start
38
18
39
- : ${POSTGRES_USER:= postgres}
40
- : ${POSTGRES_DB:= $POSTGRES_USER }
41
- export POSTGRES_USER POSTGRES_DB
42
-
43
- psql=( psql -v ON_ERROR_STOP=1 )
19
+ # : ${POSTGRES_USER:=postgres}
20
+ # : ${POSTGRES_DB:=$POSTGRES_USER}
21
+ # export POSTGRES_USER POSTGRES_DB
44
22
45
23
if [ " $POSTGRES_DB " != ' postgres' ]; then
46
- " ${ psql[@]} " --username postgres << -EOSQL
24
+ psql -U ` whoami ` postgres << -EOSQL
47
25
CREATE DATABASE "$POSTGRES_DB " ;
48
26
EOSQL
49
27
echo
50
28
fi
51
29
52
- if [ " $POSTGRES_USER " = ' postgres ' ]; then
30
+ if [ " $POSTGRES_USER " = ` whoami ` ]; then
53
31
op=' ALTER'
54
32
else
55
33
op=' CREATE'
56
34
fi
57
- " ${psql[@]} " --username postgres << -EOSQL
58
- $op USER "$POSTGRES_USER " WITH SUPERUSER $pass ;
35
+
36
+ psql -U ` whoami` postgres << -EOSQL
37
+ $op USER "$POSTGRES_USER " WITH SUPERUSER PASSWORD '';
59
38
EOSQL
60
39
echo
61
40
62
41
# ###########################################################################
63
-
64
- CONNSTRS=' dbname=postgres user=postgres host=node1, dbname=postgres user=postgres host=node2, dbname=postgres user=postgres host=node3'
65
- RAFT_PEERS=' 1:node1:6666, 2:node2:6666, 3:node3:6666'
42
+
43
+ CONNSTRS=" dbname=$POSTGRES_DB user=$POSTGRES_USER host=node1, dbname=$POSTGRES_DB user=$POSTGRES_USER host=node2, dbname=$POSTGRES_DB user=$POSTGRES_USER host=node3"
66
44
67
45
cat << -EOF >> $PGDATA /postgresql.conf
68
46
listen_addresses='*'
69
47
max_prepared_transactions = 100
70
48
synchronous_commit = on
71
49
fsync = off
72
- log_line_prefix = '%t: '
73
50
wal_level = logical
74
51
max_worker_processes = 30
75
52
max_replication_slots = 10
76
53
max_wal_senders = 10
77
54
shared_preload_libraries = 'raftable,multimaster'
78
55
default_transaction_isolation = 'repeatable read'
79
- log_checkpoints = on
80
- checkpoint_timeout = 30
81
- log_autovacuum_min_duration = 0
82
56
83
57
multimaster.workers = 4
84
- multimaster.use_raftable = false
85
58
multimaster.max_nodes = 3
86
- multimaster.use_raftable = true
59
+ multimaster.use_raftable = false
87
60
multimaster.queue_size=52857600
88
61
multimaster.ignore_tables_without_pk = 1
89
62
multimaster.node_id = $NODE_ID
@@ -93,15 +66,8 @@ if [ "$1" = 'postgres' ]; then
93
66
multimaster.twopc_min_timeout = 2000
94
67
EOF
95
68
96
- tail -n 20 $PGDATA /postgresql.conf
97
-
98
69
pg_ctl -D " $PGDATA " -m fast -w stop
99
-
100
- echo
101
- echo ' PostgreSQL init process complete; ready for start up.'
102
- echo
103
70
fi
104
71
fi
105
72
106
73
exec " $@ "
107
-
0 commit comments