# HG changeset patch # User Tom Gottfried # Date 1462530133 -7200 # Node ID 4d8b8c8499359e244b7ac4e6b125e8d189200ec0 # Parent 56d2dd058906f03879e21bf95892a717794f7f21 A bit of cleanup. diff -r 56d2dd058906 -r 4d8b8c849935 db_schema/setup-db.sh --- a/db_schema/setup-db.sh Fri May 06 12:21:48 2016 +0200 +++ b/db_schema/setup-db.sh Fri May 06 12:22:13 2016 +0200 @@ -2,12 +2,12 @@ # SYNOPSIS # ./setup-db.sh [-c] [ROLE_NAME] [ROLE_PW] [DB_NAME] # -c clean - drop an existing database -# ROLE_NAME nema of db user (default = lada) +# ROLE_NAME name of db user (default = lada) # ROLE_PW login password (default = ROLE_NAME) # DB_NAME name of the databaes (default = ROLE_NAME) # -# There will be used a remote database server if there exists the enviroment variable DB_SRV -# and optional DB_PORT +# There will be used a remote database server if there exists the +# enviroment variable DB_SRV and optional DB_PORT DIR=`dirname $0` @@ -22,7 +22,7 @@ shift $((OPTIND-1)) ROLE_NAME=${1:-lada} -echo "DROLE_NAME = $ROLE_NAME" +echo "ROLE_NAME = $ROLE_NAME" ROLE_PW=${2:-$ROLE_NAME} echo "ROLE_PW = $ROLE_PW" DB_NAME=${3:-$ROLE_NAME} @@ -30,7 +30,7 @@ # if variable DB_SRV and otional DB_PORT is set a remote database connection will be used if [ -n "$DB_SRV" ] ; then DB_CONNECT_STRING="-h $DB_SRV" ; fi -if [ -n "$DB_SRV" -a -n "$DB_PORT" ] ; then +if [ -n "$DB_SRV" -a -n "$DB_PORT" ] ; then DB_CONNECT_STRING="$DB_CONNECT_STRING -p $DB_PORT" fi DB_CONNECT_STRING="$DB_CONNECT_STRING -U postgres" @@ -50,7 +50,7 @@ psql $DB_CONNECT_STRING --command \ "CREATE DATABASE $DB_NAME WITH OWNER = $ROLE_NAME ENCODING = 'UTF8'" -echo create postgis extention +echo create postgis extension psql $DB_CONNECT_STRING -d $DB_NAME --command \ "CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public"