comparison schema/install-db.sh @ 463:5611cf72cc92

Add metamorphic database role and user e.g. for GeoServer
author Tom Gottfried <tom@intevation.de>
date Wed, 22 Aug 2018 16:48:56 +0200
parents 8feb64128c34
children ab07eb290fa3
comparison
equal deleted inserted replaced
462:62a0adc8cdcd 463:5611cf72cc92
16 Default is the postgresql standard port 5432 16 Default is the postgresql standard port 5432
17 -D, --demo also install demo accounts and data 17 -D, --demo also install demo accounts and data
18 --adminpw set the password to use for the "sysadmin" account. 18 --adminpw set the password to use for the "sysadmin" account.
19 Default is a random password. 19 Default is a random password.
20 --servicepw set the password to use for the "gemma_service" account. 20 --servicepw set the password to use for the "gemma_service" account.
21 Default is a random password.
22 --metapw set the password to use for the "meta_login" account.
21 Default is a random password. 23 Default is a random password.
22 --drop drop database and all roles 24 --drop drop database and all roles
23 --help display this help and exit 25 --help display this help and exit
24 26
25 EOF 27 EOF
44 port=5432 46 port=5432
45 demo=0 47 demo=0
46 drop=0 48 drop=0
47 adminpw=`genpw 15` 49 adminpw=`genpw 15`
48 servicepw=`genpw 15` 50 servicepw=`genpw 15`
51 metapw=`genpw 15`
49 52
50 # Parse options: 53 # Parse options:
51 54
52 OPTS=`getopt \ 55 OPTS=`getopt \
53 -l help,demo,db:,port:,drop,adminpw:,servicepw: \ 56 -l help,demo,db:,port:,drop,adminpw:,servicepw:,metapw: \
54 -o Dd:p: -n "$ME" -- "$@"` 57 -o Dd:p: -n "$ME" -- "$@"`
55 [ $? -eq 0 ] || { usage ; exit 1 ; } 58 [ $? -eq 0 ] || { usage ; exit 1 ; }
56 59
57 eval set -- "$OPTS" 60 eval set -- "$OPTS"
58 61
70 adminpw="$2" 73 adminpw="$2"
71 shift 2 74 shift 2
72 ;; 75 ;;
73 --servicepw) 76 --servicepw)
74 servicepw="$2" 77 servicepw="$2"
78 shift 2
79 ;;
80 --metapw)
81 metapw="$2"
75 shift 2 82 shift 2
76 ;; 83 ;;
77 --demo|-D) 84 --demo|-D)
78 demo=1 85 demo=1
79 shift 1 86 shift 1
118 # set passwords: 125 # set passwords:
119 psql -qt -p "$port" -d "$db" \ 126 psql -qt -p "$port" -d "$db" \
120 -c "ALTER ROLE sysadmin PASSWORD '$adminpw'" 127 -c "ALTER ROLE sysadmin PASSWORD '$adminpw'"
121 psql -qt -p "$port" -d "$db" \ 128 psql -qt -p "$port" -d "$db" \
122 -c "ALTER ROLE gemma_service PASSWORD '$servicepw'" 129 -c "ALTER ROLE gemma_service PASSWORD '$servicepw'"
130 psql -qt -p "$port" -d "$db" \
131 -c "ALTER ROLE meta_login PASSWORD '$metapw'"
123 echo "Default admin user 'sysadmin' created with password '$adminpw'." 132 echo "Default admin user 'sysadmin' created with password '$adminpw'."
124 echo "Back end user 'gemma_service' created with password '$servicepw'." 133 echo "Back end user 'gemma_service' created with password '$servicepw'."
134 echo "Back end user 'meta_login' created with password '$metapw'."
125 else 135 else
126 # Evil mode: drop everything gemma 136 # Evil mode: drop everything gemma
127 echo "Really drop database '$db' and all gemma roles? [type 'yes']: " 137 echo "Really drop database '$db' and all gemma roles? [type 'yes']: "
128 read a 138 read a
129 if [[ $a == "yes" ]] ; then 139 if [[ $a == "yes" ]] ; then