changeset 932:f5d5cc08966a

Remove wrong test operator and prepare for more options.
author Tom Gottfried <tom@intevation.de>
date Fri, 06 May 2016 12:13:15 +0200
parents 77ab53348966
children 56d2dd058906
files db_schema/setup-db.sh
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/db_schema/setup-db.sh	Wed May 04 16:04:50 2016 +0200
+++ b/db_schema/setup-db.sh	Fri May 06 12:13:15 2016 +0200
@@ -11,10 +11,15 @@
 
 DIR=`dirname $0`
 
-if [ " $1" == " -c" ] ; then 
-   DROP_DB="true"
-   shift
-fi
+while getopts "c" opt; do
+    case "$opt" in
+        c)
+            DROP_DB="true"
+            ;;
+    esac
+done
+
+shift $((OPTIND-1))
 
 ROLE_NAME=${1:-lada}
 echo "DROLE_NAME = $ROLE_NAME"
@@ -36,8 +41,8 @@
   psql $DB_CONNECT_STRING --command "CREATE USER $ROLE_NAME PASSWORD '$ROLE_PW';"
 fi
 
-if [ "$DROP_DB" == "true" ] && psql $DB_CONNECT_STRING -l | grep -q "^ $DB_NAME " ; then
-  echo drop db $DB_NAME 
+if [ "$DROP_DB" = "true" ] && psql $DB_CONNECT_STRING -l | grep -q "^ $DB_NAME " ; then
+  echo drop db $DB_NAME
   psql $DB_CONNECT_STRING --command "DROP DATABASE $DB_NAME"
 fi
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)