Skip to content

Commit bf8bfec

Browse files
committed
Update initdb logic for docker-library/postgres#75
1 parent 0e4ee6b commit bf8bfec

File tree

6 files changed

+84
-48
lines changed

6 files changed

+84
-48
lines changed

9.0-2.1/initdb-postgis.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/sh
2-
POSTGRES="gosu postgres postgres"
32

4-
$POSTGRES --single -E <<EOSQL
5-
CREATE DATABASE template_postgis
6-
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'
3+
set -e
4+
5+
# Perform all actions as user 'postgres'
6+
export PGUSER=postgres
7+
8+
# Create the 'template_postgis' template db
9+
psql <<EOSQL
10+
CREATE DATABASE template_postgis;
11+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
712
EOSQL
813

9-
POSTGIS_CONFIG=/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
10-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/postgis.sql
11-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/topology.sql
12-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/spatial_ref_sys.sql
14+
# Populate 'template_postgis'
15+
cd /usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
16+
psql --dbname template_postgis < postgis.sql
17+
psql --dbname template_postgis < topology.sql
18+
psql --dbname template_postgis < spatial_ref_sys.sql

9.1-2.1/initdb-postgis.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/sh
2-
POSTGRES="gosu postgres postgres"
32

4-
$POSTGRES --single -E <<EOSQL
5-
CREATE DATABASE template_postgis
6-
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'
3+
set -e
4+
5+
# Perform all actions as user 'postgres'
6+
export PGUSER=postgres
7+
8+
# Create the 'template_postgis' template db
9+
psql <<EOSQL
10+
CREATE DATABASE template_postgis;
11+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
712
EOSQL
813

9-
POSTGIS_CONFIG=/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
10-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/postgis.sql
11-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/topology.sql
12-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/spatial_ref_sys.sql
14+
# Populate 'template_postgis'
15+
cd /usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
16+
psql --dbname template_postgis < postgis.sql
17+
psql --dbname template_postgis < topology.sql
18+
psql --dbname template_postgis < spatial_ref_sys.sql

9.2-2.1/initdb-postgis.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/sh
2-
POSTGRES="gosu postgres postgres"
32

4-
$POSTGRES --single -E <<EOSQL
5-
CREATE DATABASE template_postgis
6-
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'
3+
set -e
4+
5+
# Perform all actions as user 'postgres'
6+
export PGUSER=postgres
7+
8+
# Create the 'template_postgis' template db
9+
psql <<EOSQL
10+
CREATE DATABASE template_postgis;
11+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
712
EOSQL
813

9-
POSTGIS_CONFIG=/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
10-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/postgis.sql
11-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/topology.sql
12-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/spatial_ref_sys.sql
14+
# Populate 'template_postgis'
15+
cd /usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
16+
psql --dbname template_postgis < postgis.sql
17+
psql --dbname template_postgis < topology.sql
18+
psql --dbname template_postgis < spatial_ref_sys.sql

9.3-2.1/initdb-postgis.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/sh
2-
POSTGRES="gosu postgres postgres"
32

4-
$POSTGRES --single -E <<EOSQL
5-
CREATE DATABASE template_postgis
6-
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'
3+
set -e
4+
5+
# Perform all actions as user 'postgres'
6+
export PGUSER=postgres
7+
8+
# Create the 'template_postgis' template db
9+
psql <<EOSQL
10+
CREATE DATABASE template_postgis;
11+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
712
EOSQL
813

9-
POSTGIS_CONFIG=/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
10-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/postgis.sql
11-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/topology.sql
12-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/spatial_ref_sys.sql
14+
# Populate 'template_postgis'
15+
cd /usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
16+
psql --dbname template_postgis < postgis.sql
17+
psql --dbname template_postgis < topology.sql
18+
psql --dbname template_postgis < spatial_ref_sys.sql

9.4-2.1/initdb-postgis.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/sh
2-
POSTGRES="gosu postgres postgres"
32

4-
$POSTGRES --single -E <<EOSQL
5-
CREATE DATABASE template_postgis
6-
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'
3+
set -e
4+
5+
# Perform all actions as user 'postgres'
6+
export PGUSER=postgres
7+
8+
# Create the 'template_postgis' template db
9+
psql <<EOSQL
10+
CREATE DATABASE template_postgis;
11+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
712
EOSQL
813

9-
POSTGIS_CONFIG=/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
10-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/postgis.sql
11-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/topology.sql
12-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/spatial_ref_sys.sql
14+
# Populate 'template_postgis'
15+
cd /usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
16+
psql --dbname template_postgis < postgis.sql
17+
psql --dbname template_postgis < topology.sql
18+
psql --dbname template_postgis < spatial_ref_sys.sql

initdb-postgis.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/sh
2-
POSTGRES="gosu postgres postgres"
32

4-
$POSTGRES --single -E <<EOSQL
5-
CREATE DATABASE template_postgis
6-
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis'
3+
set -e
4+
5+
# Perform all actions as user 'postgres'
6+
export PGUSER=postgres
7+
8+
# Create the 'template_postgis' template db
9+
psql <<EOSQL
10+
CREATE DATABASE template_postgis;
11+
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
712
EOSQL
813

9-
POSTGIS_CONFIG=/usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
10-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/postgis.sql
11-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/topology.sql
12-
$POSTGRES --single template_postgis -j < $POSTGIS_CONFIG/spatial_ref_sys.sql
14+
# Populate 'template_postgis'
15+
cd /usr/share/postgresql/$PG_MAJOR/contrib/postgis-$POSTGIS_MAJOR
16+
psql --dbname template_postgis < postgis.sql
17+
psql --dbname template_postgis < topology.sql
18+
psql --dbname template_postgis < spatial_ref_sys.sql

0 commit comments

Comments
 (0)