comparison schema/install-db.sh @ 1109:74a75a5ce770

Added geonames data and extended search for villages/cities. The free data from geonames https://download.geonames.org/ is imported into the gemma data base (for the relevant states) and used to search for cities and villages. This data might be replaced by data from the RIS-index later on..?
author Sascha Wilde <wilde@intevation.de>
date Mon, 05 Nov 2018 13:07:16 +0100
parents d1fb2babaa95
children ed8fbbc48440
comparison
equal deleted inserted replaced
1108:5adee8b0e29f 1109:74a75a5ce770
13 Options: 13 Options:
14 -d, --db=NAME create the database NAME. Default: "gemma" 14 -d, --db=NAME create the database NAME. Default: "gemma"
15 -p, --port=PORT connect do the postgresql cluster at PORT. 15 -p, --port=PORT connect do the postgresql cluster at PORT.
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 -G, --geonames also import geonames data
18 --adminpw set the password to use for the "sysadmin" account. 19 --adminpw set the password to use for the "sysadmin" account.
19 Default is a random password. 20 Default is a random password.
20 --metapw set the password to use for the "meta_login" account. 21 --metapw set the password to use for the "meta_login" account.
21 Default is a random password. 22 Default is a random password.
22 --drop drop database and all roles 23 --drop drop database and all roles
41 # Defaults: 42 # Defaults:
42 43
43 db=gemma 44 db=gemma
44 port=5432 45 port=5432
45 demo=0 46 demo=0
47 geonames=0
46 drop=0 48 drop=0
47 adminpw=`genpw 15` 49 adminpw=`genpw 15`
48 metapw=`genpw 15` 50 metapw=`genpw 15`
49 51
50 # Parse options: 52 # Parse options:
51 53
52 OPTS=`getopt \ 54 OPTS=`getopt \
53 -l help,demo,db:,port:,drop,adminpw:,metapw: \ 55 -l help,demo,geonames,db:,port:,drop,adminpw:,metapw: \
54 -o Dd:p: -n "$ME" -- "$@"` 56 -o DGd:p: -n "$ME" -- "$@"`
55 [ $? -eq 0 ] || { usage ; exit 1 ; } 57 [ $? -eq 0 ] || { usage ; exit 1 ; }
56 58
57 eval set -- "$OPTS" 59 eval set -- "$OPTS"
58 60
59 while true ; do 61 while true ; do
74 metapw="$2" 76 metapw="$2"
75 shift 2 77 shift 2
76 ;; 78 ;;
77 --demo|-D) 79 --demo|-D)
78 demo=1 80 demo=1
81 shift 1
82 ;;
83 --geonames|-G)
84 geonames=1
79 shift 1 85 shift 1
80 ;; 86 ;;
81 --drop) 87 --drop)
82 drop=1 88 drop=1
83 shift 1 89 shift 1
101 psql -q -p "$port" -f "$BASEDIR/roles.sql" -d "$db" 107 psql -q -p "$port" -f "$BASEDIR/roles.sql" -d "$db"
102 psql -qtv ON_ERROR_STOP= -p "$port" -d "$db" \ 108 psql -qtv ON_ERROR_STOP= -p "$port" -d "$db" \
103 -c "SET client_min_messages TO WARNING;" \ 109 -c "SET client_min_messages TO WARNING;" \
104 -f "$BASEDIR/isrs.sql" \ 110 -f "$BASEDIR/isrs.sql" \
105 -f "$BASEDIR/gemma.sql" \ 111 -f "$BASEDIR/gemma.sql" \
112 -f "$BASEDIR/search.sql" \
113 -f "$BASEDIR/geonames.sql" \
106 -f "$BASEDIR/manage_users.sql" \ 114 -f "$BASEDIR/manage_users.sql" \
107 -f "$BASEDIR/auth.sql" \ 115 -f "$BASEDIR/auth.sql" \
108 -f "$BASEDIR/default_sysconfig.sql" 116 -f "$BASEDIR/default_sysconfig.sql"
117
109 118
110 # setup initial login roles with given passwords: 119 # setup initial login roles with given passwords:
111 psql -qt -P pager=off -p "$port" -d "$db" \ 120 psql -qt -P pager=off -p "$port" -d "$db" \
112 -v adminpw="$adminpw" -v metapw="$metapw" \ 121 -v adminpw="$adminpw" -v metapw="$metapw" \
113 -f "$BASEDIR/std_login_roles.sql" 122 -f "$BASEDIR/std_login_roles.sql"
116 psql -qv ON_ERROR_STOP= -p "$port" \ 125 psql -qv ON_ERROR_STOP= -p "$port" \
117 -f "$BASEDIR/demo-data/responsibility_areas.sql" \ 126 -f "$BASEDIR/demo-data/responsibility_areas.sql" \
118 -f "$BASEDIR/demo-data/users.sql" -d "$db" 127 -f "$BASEDIR/demo-data/users.sql" -d "$db"
119 psql -q -p "$port" -f "$BASEDIR/demo-data/roles.sql" \ 128 psql -q -p "$port" -f "$BASEDIR/demo-data/roles.sql" \
120 -d "$db" 129 -d "$db"
130 fi
121 131
132 if [[ $geonames -eq 1 ]] ; then
133 "$BASEDIR/geonames-import/import-geonames.sh" -p "$port" -d "$db"
122 fi 134 fi
123 135
124 else 136 else
125 # Evil mode: drop everything gemma 137 # Evil mode: drop everything gemma
126 echo "Really drop database '$db' and all gemma roles? [type 'yes']: " 138 echo "Really drop database '$db' and all gemma roles? [type 'yes']: "