colouring-montreal/init-user-db.sh

33 lines
1.7 KiB
Bash
Raw Normal View History

2022-02-08 05:31:54 -05:00
#!/bin/bash
2022-02-08 09:05:12 -05:00
service postgresql start
sudo apt-get install -y postgresql-contrib libpq-dev postgis
sudo apt-get install -y postgresql-14-postgis-3
sudo apt-get install -y gdal-bin libspatialindex-dev libgeos-dev libproj-dev
sed -i "s/#\?listen_address.*/listen_addresses '*'/" /etc/postgresql/14/main/postgresql.conf
echo "host all all all md5" | tee --append /etc/postgresql/14/main/pg_hba.conf > /dev/null
2022-02-08 05:31:54 -05:00
service postgresql restart
sudo -u postgres psql -c "SELECT 1 FROM pg_user WHERE usename = 'dockeruser';" | grep -q 1 || sudo -u postgres psql -c "CREATE ROLE dockeruser SUPERUSER LOGIN PASSWORD 'postgres';"
sudo -u postgres psql -c "SELECT 1 FROM pg_database WHERE datname = 'colouringlondon';" | grep -q 1 || sudo -u postgres createdb -E UTF8 -T template0 --locale=en_US.utf8 -O dockeruser colouringlondon
psql -d colouringlondon -U dockeruser -h localhost
psql -d colouringlondon -c "create extension postgis;"
psql -d colouringlondon -c "create extension pgcrypto;"
psql -d colouringlondon -c "create extension pg_trgm;"
2022-02-08 05:48:36 -05:00
ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql -d colouringlondon < $migration; done;
pyvenv colouringlondon
source colouringlondon/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r ./colouring-london/etl/requirements.txt
python ./colouring-london/app/etl/get_test_polygons.py
./colouring-london/app/etl/load_geometries_cl.sh ./
psql -d colouringlondon < ./colouring-london/app/migrations/002.index-geometries.up.sql
./create_building_records_cl.sh
psql -d colouringlondon < ./colouring-london/app/migrations/003.index-buildings.up.sql
2022-02-08 05:31:54 -05:00
ls ./colouring-london/migrations/*.up.sql 2>/dev/null | while read -r migration; do psql -d colouringlondon < $migration; done;