File: setup_postgres.sh

package info (click to toggle)
python-geopandas 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,752 kB
  • sloc: python: 26,021; makefile: 147; sh: 25
file content (33 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
set -e

if [ -z "${PGUSER}" ] || [ -z "${PGPORT}" ]; then
    echo "Environment variables PGUSER and PGPORT must be set"
    exit 1
fi

PGDATA=$(mktemp -d /tmp/postgres.XXXXXX)
echo "Setting up PostgreSQL in ${PGDATA} on port ${PGPORT}"

pg_ctl -D ${PGDATA} initdb
pg_ctl -D ${PGDATA} start

SOCKETPATH="/tmp/.s.PGSQL.${PGPORT}"
echo -n 'waiting for postgres'
while [ ! -e ${SOCKETPATH} ]; do
    sleep 1
    echo -n '.'
done
echo

echo "Done setting up PostgreSQL. When finished, stop and cleanup using:"
echo
echo "    pg_ctl -D ${PGDATA} stop"
echo "    rm -rf ${PGDATA}"
echo

createuser -U ${USER} -s ${PGUSER}
createdb --owner=${PGUSER} test_geopandas
psql -d test_geopandas -q -c "CREATE EXTENSION postgis"

echo "PostGIS server ready."