forked from drnoa/sqlledger_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupervisord-postgresql.sh
More file actions
24 lines (19 loc) · 1022 Bytes
/
supervisord-postgresql.sh
File metadata and controls
24 lines (19 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Exit immediately if a simple command exits with a non-zero status
set -e
POSTGRESQL_BIN=/usr/lib/postgresql/9.1/bin/postgres
POSTGRESQL_CONFIG_FILE=/etc/postgresql/9.1/main/postgresql.conf
POSTGRESQL_DATA=/var/lib/postgresql/9.1/main
POSTGRESQL_SINGLE="sudo -u postgres $POSTGRESQL_BIN --single --config-file=$POSTGRESQL_CONFIG_FILE"
# If there is no postgresql data directory, create the directory and set config data path
if [ ! -d $POSTGRESQL_DATA ]; then
mkdir -p $POSTGRESQL_DATA
chown -R postgres:postgres $POSTGRESQL_DATA
sudo -u postgres /usr/lib/postgresql/9.1/bin/initdb -D $POSTGRESQL_DATA
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem $POSTGRESQL_DATA/server.crt
ln -s /etc/ssl/private/ssl-cert-snakeoil.key $POSTGRESQL_DATA/server.key
fi
# Setting the default password
$POSTGRESQL_SINGLE <<< "ALTER USER postgres WITH PASSWORD 'change@this*passw0rd';" > /dev/null
# Starting the postgresql server
exec sudo -u postgres $POSTGRESQL_BIN --config-file=$POSTGRESQL_CONFIG_FILE