]> Git — Sourcephile - gargantext.git/blob - devops/postgres/create
[FEAT] Phylo update
[gargantext.git] / devops / postgres / create
1 #!/bin/bash
2
3 # sudo su postgres
4 # postgresql://$USER:$PW@localhost/$DB
5
6 INIFILE=$1
7
8 getter () {
9 grep $1 $INIFILE | sed "s/^.*= //"
10 }
11
12 USER=$(getter "DB_USER")
13 NAME=$(getter "DB_NAME")
14 PASS=$(getter "DB_PASS")
15 HOST=$(getter "DB_HOST")
16 PORT=$(getter "DB_PORT")
17
18
19 psql -c "CREATE USER \"${USER}\""
20 psql -c "ALTER USER \"${USER}\" with PASSWORD '${PW}'"
21 psql -c "DROP DATABASE IF EXISTS \"${NAME}\""
22
23 createdb "${NAME}"
24 psql "${NAME}" < extensions.sql
25
26 # if new
27 #psql "${NAME}" < schema.sql
28
29 psql ${NAME} < $2
30
31 psql -c "ALTER DATABASE \"${NAME}\" OWNER to \"${USER}\""
32
33