diff --git a/scripts/create_database.sh b/scripts/create_database.sh index df23b1d..6e9cf07 100755 --- a/scripts/create_database.sh +++ b/scripts/create_database.sh @@ -3,27 +3,31 @@ # utiliser un compte SUPERUSER pour exécuter ce script -dbhost=localhost +millesime=2022 -#psql -h $dbhost -d postgres -c "DROP DATABASE IF EXISTS redadeg; DROP ROLE IF EXISTS redadeg;" +PSQL=/usr/bin/psql +DB_HOST=localhost +DB_NAME=redadeg_$millesime + +psql -h $dbhost -d postgres -c "DROP DATABASE IF EXISTS $DB_NAME; DROP ROLE IF EXISTS redadeg;" # create role psql -h $dbhost -d postgres -c "CREATE USER redadeg WITH PASSWORD 'redadeg' SUPERUSER;" # create database with owner redadeg -psql -h $dbhost -d postgres -c "CREATE DATABASE redadeg WITH OWNER = redadeg ENCODING = 'UTF8';" +psql -h $dbhost -d postgres -c "CREATE DATABASE $DB_NAME WITH OWNER = redadeg ENCODING = 'UTF8';" # extensions postgis -psql -h $dbhost -d redadeg -c "CREATE EXTENSION postgis;" -psql -h $dbhost -d redadeg -c "CREATE EXTENSION postgis_topology;" -psql -h $dbhost -d redadeg -c "CREATE EXTENSION pgrouting;" +psql -h $dbhost -d $DB_NAME -c "CREATE EXTENSION postgis;" +psql -h $dbhost -d $DB_NAME -c "CREATE EXTENSION postgis_topology;" +psql -h $dbhost -d $DB_NAME -c "CREATE EXTENSION pgrouting;" # permissions -psql -h $dbhost -d redadeg -c "ALTER SCHEMA public OWNER TO redadeg;" -psql -h $dbhost -d redadeg -c "ALTER TABLE topology.layer OWNER TO redadeg ;" -psql -h $dbhost -d redadeg -c "ALTER TABLE topology.topology OWNER TO redadeg ;" +psql -h $dbhost -d $DB_NAME -c "ALTER SCHEMA public OWNER TO redadeg;" +psql -h $dbhost -d $DB_NAME -c "ALTER TABLE topology.layer OWNER TO redadeg ;" +psql -h $dbhost -d $DB_NAME -c "ALTER TABLE topology.topology OWNER TO redadeg ;" # vérifications -psql -h $dbhost -d redadeg -c "SELECT * FROM postgis_version();" -psql -h $dbhost -d redadeg -c "SELECT * FROM pgr_version();" +psql -h $dbhost -d $DB_NAME -c "SELECT * FROM postgis_version();" +psql -h $dbhost -d $DB_NAME -c "SELECT * FROM pgr_version();" diff --git a/scripts/load_communes_osm_br.sh b/scripts/load_communes_osm_br.sh index a0ed64c..b25ece5 100755 --- a/scripts/load_communes_osm_br.sh +++ b/scripts/load_communes_osm_br.sh @@ -5,7 +5,7 @@ set -u PSQL=/usr/bin/psql DB_HOST=localhost -DB_NAME=redadeg +DB_NAME=redadeg_$millesime DB_USER=redadeg DB_PASSWD=redadeg diff --git a/scripts/load_communes_osm_fr.sh b/scripts/load_communes_osm_fr.sh index b1452a3..0861dad 100755 --- a/scripts/load_communes_osm_fr.sh +++ b/scripts/load_communes_osm_fr.sh @@ -3,19 +3,23 @@ set -e set -u +millesime=2022 + PSQL=/usr/bin/psql DB_HOST=localhost -DB_NAME=redadeg +DB_NAME=redadeg_$millesime DB_USER=redadeg DB_PASSWD=redadeg # ce script récupère une couche des communes de France et la charge dans la base de données -cd data +mkdir -p ../data/$millesime/ +cd ../data/$millesime/ # récupérer la couche communales OSM # https://www.data.gouv.fr/fr/datasets/decoupage-administratif-communal-francais-issu-d-openstreetmap/ -curl -sS http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20210101-shp.zip > communes-20210101-shp.zip +#curl -sS http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20210101-shp.zip > communes-20210101-shp.zip +wget http://osm13.openstreetmap.fr/~cquest/openfla/export/communes-20210101-shp.zip unzip -o communes-20210101-shp.zip