setup_test_db.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. if [ -z $(which initdb) ] ; then
  3. echo "Postgres not found, you may need to launch like so: PATH=\$PATH:/usr/lib/postgresql/9.3/bin/ $0"
  4. exit 1
  5. fi
  6. ## Thanks to Matwey V. Kornilov ( https://github.com/matwey ) for
  7. ## this:
  8. initdb --locale en_US.UTF-8 datadir
  9. cat > datadir/postgresql.conf <<EOF
  10. ssl = on
  11. ssl_ca_file = 'root.crt'
  12. EOF
  13. cp test_data/epgsql.crt datadir/server.crt
  14. cp test_data/epgsql.key datadir/server.key
  15. cp test_data/root.crt datadir/root.crt
  16. cp test_data/root.key datadir/root.key
  17. chmod 0600 datadir/server.key
  18. cat > datadir/pg_hba.conf <<EOF
  19. local all $USER trust
  20. host template1 $USER 127.0.0.1/32 trust
  21. host $USER $USER 127.0.0.1/32 trust
  22. host epgsql_test_db1 $USER 127.0.0.1/32 trust
  23. host epgsql_test_db1 epgsql_test 127.0.0.1/32 trust
  24. host epgsql_test_db1 epgsql_test_md5 127.0.0.1/32 md5
  25. host epgsql_test_db1 epgsql_test_cleartext 127.0.0.1/32 password
  26. hostssl epgsql_test_db1 epgsql_test_cert 127.0.0.1/32 cert clientcert=1
  27. EOF