changeset 331:a85f56207d80

db-setup script: Allow to set passwords manually. Especially during testing, when setting up a fresh db it is desirable to set the passwords to well known values instead of getting fresh random ones. This is now possible.
author Sascha Wilde <wilde@intevation.de>
date Fri, 03 Aug 2018 13:52:23 +0200
parents fd04bccae6ca
children 394fafeb4052
files schema/install-db.sh
diffstat 1 files changed, 16 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/schema/install-db.sh	Fri Aug 03 13:40:10 2018 +0200
+++ b/schema/install-db.sh	Fri Aug 03 13:52:23 2018 +0200
@@ -15,6 +15,10 @@
   -p, --port=PORT  connect do the postgresql cluster at PORT.
                    Default is the postgresql standard port 5432
   -D, --demo       also install demo accounts and data
+      --adminpw    set the password to use for the "sysadmin" account.
+                   Default is a random password.
+      --servicepw  set the password to use for the "gemma_service" account.
+                   Default is a random password.
       --drop       drop database and all roles
       --help       display this help and exit
 
@@ -40,11 +44,13 @@
 port=5432
 demo=0
 drop=0
+adminpw=`genpw 15`
+servicepw=`genpw 15`
 
 # Parse options:
 
 OPTS=`getopt \
-      -l help,demo,db:,port:,drop \
+      -l help,demo,db:,port:,drop,adminpw:,servicepw: \
       -o Dd:p: -n "$ME" -- "$@"`
 [ $? -eq 0 ] || { usage ; exit 1 ; }
 
@@ -60,6 +66,14 @@
       port="$2"
       shift 2
       ;;
+    --adminpw)
+      adminpw="$2"
+      shift 2
+      ;;
+    --servicepw)
+      servicepw="$2"
+      shift 2
+      ;;
     --demo|-D)
       demo=1
       shift 1
@@ -98,11 +112,7 @@
     psql -q -p "$port" -f "$BASEDIR/demo-data/roles.sql" \
          -f "$BASEDIR/demo-data/users.sql" -d "$db"
   fi
-
-  # Generate and set Passwords
-  adminpw=`genpw 15`
-  servicepw=`genpw 15`
-
+  # set passwords:
   psql -qt -p "$port" -d "$db" \
        -c "ALTER ROLE sysadmin PASSWORD '$adminpw'"
   psql -qt -p "$port" -d "$db" \