#!/bin/bash INIFILE=$1 getter () { grep $1 $INIFILE | sed "s/^.*= //" } 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}" } if [[ $1 == "" ]] then echo "USAGE : ./psql gargantext.ini" else connect $1 fi