#!/bin/sh
set -xe

DCI_DB_DIR=${DCI_DB_DIR:-".db_dir"}
DCI_DB_HOST=${DCI_DB_HOST:-"127.0.0.1"}

# get dci_db_dir absolute path
DCI_DB_DIR="$(cd "$(dirname "$0")/.." && pwd)/$DCI_DB_DIR"

# if the database is already running we do not want to run this script
[ ! -z "$DISABLE_DB_START" ] &&exit 0

# checks if pg_ctl command exists
type "pg_ctl"

# checks if not already running
pg_ctl status -D "$DCI_DB_DIR" &> /dev/null && pg_ctl stop -D "$DCI_DB_DIR"

[ -d "$DCI_DB_DIR" ] && rm -rf "$DCI_DB_DIR"

OPTIONS="--client-encoding=utf8 --full-page_writes=off \
         --logging-collector=off --log-destination='stderr'"

# init the database directory and start the process
pg_ctl initdb -D "$DCI_DB_DIR" -o "--no-locale"
pg_ctl start -w -D "$DCI_DB_DIR" -o "-k $DCI_DB_DIR -F -h $DCI_DB_HOST $OPTIONS"

#!/bin/sh
set -xe

DCI_DB_DIR=${DCI_DB_DIR:-".db_dir"}

# get dci_db_dir absolute path
DCI_DB_DIR="$(cd "$(dirname "$0")/.." && pwd)/$DCI_DB_DIR"

# if the database is already running we do not want to run this script
[ ! -z "$DISABLE_DB_START" ] &&exit 0

# checks if pg_ctl command exists
type "pg_ctl"

# checks if not already running
pg_ctl status -D "$DCI_DB_DIR" &> /dev/null && pg_ctl stop -D "$DCI_DB_DIR"

[ -d "$DCI_DB_DIR" ] && rm -rf "$DCI_DB_DIR"

OPTIONS="--client-encoding=utf8 --full-page_writes=off \
         --logging-collector=off --log-destination='stderr'"

# init the database directory and start the process
pg_ctl initdb -D "$DCI_DB_DIR" -o "--no-locale"
pg_ctl start -w -D "$DCI_DB_DIR" -o "-k $DCI_DB_DIR -F -h '' $OPTIONS"

Revert "Be able to configure the database host in the startup script"
Revert "Be able to configure the database host in the startup script"

This reverts commit 31020d107e2526bf1c63299151b9312838148e9d.

Change-Id: Ic929d2652785dbeb8ff45dbd88a79bd3f1b20602
