v2 : create database
This commit is contained in:
parent
c12f764f79
commit
b1c879fc77
6
scripts_v2/config.sh
Normal file → Executable file
6
scripts_v2/config.sh
Normal file → Executable file
|
@ -1,16 +1,10 @@
|
|||
#! /bin/bash
|
||||
|
||||
|
||||
# exit dès que qqch se passe mal
|
||||
set -e
|
||||
# sortir si "unbound variqble"
|
||||
#set -u
|
||||
|
||||
# argument 1 passé au script = millesime redadeg
|
||||
millesime=$1
|
||||
|
||||
|
||||
|
||||
# configuration des infos de connexions aux bases de données
|
||||
# >>>> pas besoin de mettre ces infos dans le .pgpass <<<<<
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#! /bin/bash
|
||||
|
||||
# exit dès que qqch se passe mal
|
||||
set -e
|
||||
# sortir si "unbound variable"
|
||||
#set -u
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
|
@ -26,25 +30,26 @@ echo ""
|
|||
# create role
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASSWD' SUPERUSER;" || true
|
||||
|
||||
# suppression de la base de données existantes
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "DROP DATABASE $DB_NAME ;" || true
|
||||
# suppression de la base de donnée existante
|
||||
# on stoppe si impossible genre des connectiosn en cours
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "DROP DATABASE $DB_NAME ;"
|
||||
|
||||
# create database with owner redadeg
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "CREATE DATABASE $DB_NAME WITH OWNER = $DB_USER ENCODING = 'UTF8';" || true
|
||||
|
||||
# extensions postgis
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "CREATE EXTENSION postgis;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "CREATE EXTENSION postgis_topology;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "CREATE EXTENSION pgrouting;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "CREATE EXTENSION postgis;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "CREATE EXTENSION postgis_topology;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "CREATE EXTENSION pgrouting;" || true
|
||||
|
||||
# permissions
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "ALTER SCHEMA public OWNER TO $DB_USER;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "ALTER TABLE topology.layer OWNER TO $DB_USER ;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "ALTER TABLE topology.topology OWNER TO $DB_USER ;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "ALTER SCHEMA public OWNER TO $DB_USER;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "ALTER TABLE topology.layer OWNER TO $DB_USER ;" || true
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "ALTER TABLE topology.topology OWNER TO $DB_USER ;" || true
|
||||
|
||||
# vérifications
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "SELECT * FROM postgis_version();"
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d postgres -U $DB_USER -c "SELECT * FROM pgr_version();"
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "SELECT * FROM postgis_version();"
|
||||
PGPASSWORD=$DB_PASSWD $PSQL -h $DB_HOST -p $DB_PORT -d $DB_NAME -U $DB_USER -c "SELECT * FROM pgr_version();"
|
||||
|
||||
|
||||
echo ""
|
||||
|
|
Loading…
Reference in a new issue