-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·36 lines (25 loc) · 1.06 KB
/
entrypoint.sh
File metadata and controls
executable file
·36 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# copy of https://github.com/gisgraphy/gisgraphy-docker/blob/master/base/assets/install-gisgraphy.sh
set -e
DB_PROPS="/usr/local/gisgraphy/webapps/ROOT/WEB-INF/classes/jdbc.properties"
envsubst '\$PG_USER \$PG_PASS \$PG_HOST \$GISGRAPHY_DB' < /usr/local/gisgraphy/jdbc.properties > $DB_PROPS
function does_db_exist() {
psql -U $PG_USER -h $PG_HOST -lqt | cut -d \| -f 1 | grep -wq $1
}
function db_setup() {
DB_NAME="gisgraphy"
sleep 10 # wait for db to be up
export PGPASSWORD=$PG_PASS
if does_db_exist $DB_NAME
then
echo -e "$DB_NAME db exists, skipping create"
else
echo -e "$DB_NAME db does not exist, creating"
psql -U $PG_USER -h $PG_HOST -c "CREATE DATABASE gisgraphy ENCODING = 'UTF8';"
psql -U $PG_USER -h $PG_HOST -d gisgraphy -f /usr/local/gisgraphy/sql/create_tables.sql
psql -U $PG_USER -h $PG_HOST -d gisgraphy -f /usr/local/gisgraphy/sql/insert_users.sql
psql -U $PG_USER -h $PG_HOST -d gisgraphy -f /usr/local/gisgraphy/sql/createGISTIndex.sql
fi
}
db_setup
exec "$@"