I am working on this Bash Script for Dockerfile:
#!/bin/bash
set -e
gosu postgres postgres --single -jE <<-EOL
CREATE USER "$OSM_USER";
EOL
gosu postgres postgres --single -jE <<-EOL
CREATE DATABASE "$OSM_DB";
EOL
gosu postgres postgres --single -jE <<-EOL
GRANT ALL ON DATABASE "$OSM_DB" TO "$OSM_USER";
EOL
# Postgis extension cannot be created in single user mode.
# So we will do it the kludge way by starting the server,
# updating the DB, then shutting down the server so the
# rest of the docker-postgres init scripts can finish.
gosu postgres pg_ctl -w start
gosu postgres psql "$OSM_DB" <<-EOL
CREATE EXTENSION postgis;
CREATE EXTENSION hstore;
ALTER TABLE geometry_columns OWNER TO "$OSM_USER";
ALTER TABLE spatial_ref_sys OWNER TO "$OSM_USER";
EOL
gosu postgres pg_ctl stop
i wan to add two import commands after ALTER TABLE:
shp2pgsql -I -s 4326 -W "latin1" post_pl.shp post_pl > post_pl.sql
psql -h 172.17.0.2 -U postgres -d gis -f post_pl.sql
osm2pgsql -H 172.17.0.2 -U postgres -d gis --hstore -s -S `./osm_stylesheet ./hessen-latest.osm.pbf`
My question is, can it work? Can we import data when we inside psql? And if yes, how can i do it?
TNX
Andrey Ramnikov