taler-windows

Windows packaging
Log | Files | Refs

test-db.sh (1093B)


      1 #!/bin/bash
      2 # test-db.sh
      3 # Usage: ./test-db.sh <POSTGRES_URL>
      4 mkdir -p /home/taleruser/taler-installer 2>/dev/null
      5 echo "=== [DEBUG] test-db.sh called ===" | tee -a /home/taleruser/taler-installer/test-db.log
      6 # Never echo $1: it carries the database password, and this log is kept
      7 # for support.  "${1##*@}" drops everything up to the last "@", which is
      8 # the credentials -- a PostgreSQL URI cannot carry an unescaped "@" in
      9 # them -- and leaves the host and database name, which is the part worth
     10 # having when a connection fails.
     11 echo "Received URL (credentials stripped): ${1##*@}" | tee -a /home/taleruser/taler-installer/test-db.log
     12 POSTGRES_URL="$1"
     13 
     14 echo "Testing ${POSTGRES_URL##*@}" > /tmp/dbtest.log
     15 
     16 if command -v psql >/dev/null 2>&1; then
     17     if psql "$POSTGRES_URL" -c '\q' >> /tmp/dbtest.log 2>&1; then
     18         echo "OK"
     19         echo "Exit code: 0" >> /tmp/dbtest.log
     20         exit 0
     21     else
     22         echo "ERROR"
     23         echo "Exit code: 1" >> /tmp/dbtest.log
     24         exit 1
     25     fi
     26 else
     27     echo "psql command not found"
     28     echo "Exit code: 2" >> /tmp/dbtest.log
     29     exit 2
     30 fi