4 filename: /etc/service/unicorn/run
6 to: sv start postgres || exit 1
9 - exec: mkdir -p /shared/postgres_run
10 - exec: chown postgres:postgres /shared/postgres_run
11 - exec: chmod 775 /shared/postgres_run
12 - exec: rm -fr /var/run/postgresql
13 - exec: ln -s /shared/postgres_run /var/run/postgresql
14 - exec: socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
16 path: /etc/service/postgres/run
21 exec sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main
25 - chown -R root /var/lib/postgresql/9.2/main
26 - "[ ! -e /shared/postgres_data ] && install -d -m 0755 -o postgres -g postgres /shared/postgres_data && sudo -u postgres /usr/lib/postgresql/9.2/bin/initdb -D /shared/postgres_data || exit 0"
27 - chown -R postgres:postgres /shared/postgres_data
30 filename: "/etc/postgresql/9.2/main/postgresql.conf"
31 from: "data_directory = '/var/lib/postgresql/9.2/main'"
32 to: "data_directory = '/shared/postgres_data'"
34 # listen on all interfaces
36 filename: "/etc/postgresql/9.2/main/postgresql.conf"
37 from: /#?listen_addresses *=.*/
38 to: "listen_addresses = '*'"
40 # Necessary to enable backups
43 - install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
46 filename: "/etc/postgresql/9.2/main/postgresql.conf"
47 from: /#?max_wal_senders *=.*/
48 to: "max_wal_senders = 4"
51 filename: "/etc/postgresql/9.2/main/postgresql.conf"
52 from: /#?wal_level *=.*/
53 to: "wal_level = hot_standby"
56 filename: "/etc/postgresql/9.2/main/pg_hba.conf"
57 from: /^#local +replication +postgres +peer$/
58 to: "local replication postgres peer"
60 # allow all to connect in with md5 auth
62 filename: "/etc/postgresql/9.2/main/pg_hba.conf"
63 from: /^host.*all.*all.*127.*$/
64 to: "host all all 0.0.0.0/0 md5"
68 cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
70 # give db a few secs to start up
73 - exec: sudo -u postgres createdb discourse || exit 0
76 create user discourse;
77 cmd: sudo -u postgres psql discourse
82 grant all privileges on database discourse to discourse;
83 cmd: sudo -u postgres psql discourse
86 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "alter schema public owner to discourse;"'
87 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
88 - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
91 update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = 'discourse' AND encoding = pg_encoding_to_char('SQL_ASCII');
92 cmd: sudo -u postgres psql discourse
97 cmd: "echo postgres installed!"