Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions config/database.yml.default

This file was deleted.

2 changes: 0 additions & 2 deletions config/database.yml.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# SQLite version 3.x
# gem install sqlite3
development:
adapter: postgresql
encoding: unicode
Expand Down
67 changes: 37 additions & 30 deletions script/install/postgresql.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,58 @@ cd `dirname $0`/../..

source script/install.cfg

min_version=8

psql --version 2>/dev/null | bash script/extract_version.bash | bash script/check_version.bash $min_version || {
echo PostgreSQL $min_version+ required!
bash script/confirm.bash 'Install PostgreSQL' && {
cmd="sudo apt-get install postgresql"
echo "$ $cmd"
$cmd
} || exit 1

}

# required by pg gem
# header files (required by pg gem)
cmd="sudo apt-get install libpq-dev"
echo "$ $cmd"
$cmd || exit 1

# setup user if required
psql -U$DATABASE_USERNAME postgres -c '' &> /dev/null || {
bash script/confirm.bash "Create new PostgreSQL user $DATABASE_USERNAME" && {
cmd="sudo -u postgres createuser --superuser $DATABASE_USERNAME"
echo "$ $cmd"
$cmd
} || exit 1
# client utilities (psql, createdb, pg_dump, etc.)
command -v psql >/dev/null || {
cmd="sudo apt-get install postgresql-client"
echo "$ $cmd"
$cmd || exit 1
}

# setup database if required
if [[ $DATABASE ]] ; then
psql -U$DATABASE_USERNAME $DATABASE -c '' &> /dev/null || {
bash script/confirm.bash "Create new PostgreSQL database $DATABASE" && {
cmd="sudo -u postgres createdb $DATABASE"
if [ "${DATABASE_INSTALL:-true}" = "true" ]; then
# install server (not required if the server is running on another host/container)
id -u postgres &> /dev/null || {
echo "PostgreSQL server required!"
bash script/confirm.bash 'Install PostgreSQL server' && {
cmd="sudo apt-get install postgresql"
echo "$ $cmd"
$cmd
} || exit 1
}

# setup user if required
psql -U "$DATABASE_USERNAME" postgres -c '' &> /dev/null || {
bash script/confirm.bash "Create new PostgreSQL user $DATABASE_USERNAME" && {
cmd="sudo -u postgres createuser --superuser $DATABASE_USERNAME"
echo "$ $cmd"
$cmd
} || exit 1
}
fi

# setup database if required
if [[ $DATABASE ]] ; then
psql -U "$DATABASE_USERNAME" "$DATABASE" -c '' &> /dev/null || {
bash script/confirm.bash "Create new PostgreSQL database $DATABASE" && {
cmd=(createdb -U "$DATABASE_USERNAME" "$DATABASE")
echo "$ ${cmd[@]}"
"${cmd[@]}"
} || exit 1
}
fi

# setup test database if required
if [[ $TEST_DATABASE ]] ; then
psql -U$DATABASE_USERNAME $TEST_DATABASE -c '' &> /dev/null || {
psql -U "$DATABASE_USERNAME" "$TEST_DATABASE" -c '' &> /dev/null || {
bash script/confirm.bash "Create new PostgreSQL database $TEST_DATABASE" && {
cmd="sudo -u postgres createdb $TEST_DATABASE"
echo "$ $cmd"
$cmd
} || exit
cmd=(createdb -U "$DATABASE_USERNAME" "$TEST_DATABASE")
echo "$ ${cmd[@]}"
"${cmd[@]}"
} || exit 1
}
fi