Skip to content
Prev Previous commit
Next Next commit
bootstrap: move postgres setup to separate script
  • Loading branch information
lightmare committed Aug 22, 2019
commit 7426180dab84d6e8a8345061a744cbaaa6b89c5b
22 changes: 0 additions & 22 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function install_mason_deps() {
# deps needed by python-mapnik (not mapnik core)
install boost_libthread 1.63.0
install boost_libpython 1.63.0
install postgis 2.3.2-1
}

function setup_runtime_settings() {
Expand All @@ -46,29 +45,8 @@ function setup_runtime_settings() {
echo "export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}" >> mason-config.env
echo "export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal" >> mason-config.env
echo "export PATH=$(pwd)/mason_packages/.link/bin:${PATH}" >> mason-config.env
echo "export PGTEMP_DIR=$(pwd)/local-tmp" >> mason-config.env
echo "export PGDATA=$(pwd)/local-postgres" >> mason-config.env
echo "export PGHOST=$(pwd)/local-unix-socket" >> mason-config.env
echo "export PGPORT=1111" >> mason-config.env

source mason-config.env
rm -rf ${PGHOST}
mkdir -p ${PGHOST}
rm -rf ${PGDATA}
mkdir -p ${PGDATA}
rm -rf ${PGTEMP_DIR}
mkdir -p ${PGTEMP_DIR}
./mason_packages/.link/bin/initdb
sleep 2
./mason_packages/.link/bin/postgres -k ${PGHOST} > postgres.log &
sleep 2
./mason_packages/.link/bin/createdb template_postgis -T postgres
./mason_packages/.link/bin/psql template_postgis -c "CREATE TABLESPACE temp_disk LOCATION '${PGTEMP_DIR}';"
./mason_packages/.link/bin/psql template_postgis -c "SET temp_tablespaces TO 'temp_disk';"
./mason_packages/.link/bin/psql template_postgis -c "CREATE PROCEDURAL LANGUAGE 'plpythonu' HANDLER plpython_call_handler;"
./mason_packages/.link/bin/psql template_postgis -c "CREATE EXTENSION postgis;"
./mason_packages/.link/bin/psql template_postgis -c "SELECT PostGIS_Full_Version();"
./mason_packages/.link/bin/pg_ctl -w stop
}

function main() {
Expand Down
23 changes: 23 additions & 0 deletions scripts/setup_postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash

function setup_postgres_settings() {
export PGDATA=$PWD/local-postgres
export PGHOST=$PWD/local-unix-socket
export PGPORT=1111
}

function setup_postgres() {
rm -rf -- "$PGDATA" "$PGHOST"
mkdir -p -- "$PGDATA" "$PGHOST"

initdb -N
postgres -k "$PGHOST" -c fsync=off > postgres.log &
sleep 2
createdb template_postgis -T postgres
psql template_postgis -e -c "CREATE PROCEDURAL LANGUAGE 'plpythonu' HANDLER plpython_call_handler;"
psql template_postgis -e -c "CREATE EXTENSION postgis;"
psql template_postgis -e -c "SELECT PostGIS_Full_Version();"
}

setup_postgres_settings
setup_postgres