#!/bin/bash

PGPASS_FILE='/root/.pgpass'
CREDENTIALS="localhost:5432:postgres:postgres:proformatique"

if [ -f $PGPASS_FILE ]; then
  if ! grep -Fxq "${CREDENTIALS}" $PGPASS_FILE; then
    echo "${CREDENTIALS}" >> $PGPASS_FILE
  fi
else
  echo "${CREDENTIALS}" > $PGPASS_FILE
  chmod 600 $PGPASS_FILE
fi

exit 0