Mercurial > lada > lada-server
diff db_schema/setup-db.sh @ 934:4d8b8c849935
A bit of cleanup.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 06 May 2016 12:22:13 +0200 |
parents | 56d2dd058906 |
children | bc44dcda6f69 |
line wrap: on
line diff
--- 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"