Commit 92eaa227 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[UTIL] psql refactored

parent 585d78b4
#!/bin/bash #!/bin/bash
if [[ $1 == "" ]] INIFILE=$1
then echo "USAGE : ./psql gargantext.ini"
else
getter () {
grep $2 $1 | sed "s/^.*= //"
}
USER=$(getter $1 "DB_USER")
NAME=$(getter $1 "DB_NAME")
PASS=$(getter $1 "DB_PASS") getter () {
HOST=$(getter $1 "DB_HOST") grep $1 $INIFILE | sed "s/^.*= //"
PORT=$(getter $1 "DB_PORT") }
connect () {
USER=$(getter "DB_USER")
NAME=$(getter "DB_NAME")
PASS=$(getter "DB_PASS")
HOST=$(getter "DB_HOST")
PORT=$(getter "DB_PORT")
psql "postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}"
}
psql "postgresql://${USER}:${PASS}@${HOST}:${PORT}/${NAME}" if [[ $1 == "" ]]
then echo "USAGE : ./psql gargantext.ini"
else connect $1
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment