setup_test_db.sh 1.1 KB

123456789101112131415161718192021222324252627282930
  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. echo "ssl = on" >> datadir/postgresql.conf
  10. cp test_data/epgsql.crt datadir/server.crt
  11. cp test_data/epgsql.key datadir/server.key
  12. cp test_data/root.crt datadir/root.crt
  13. cp test_data/root.key datadir/root.key
  14. chmod 0600 datadir/server.key
  15. cat > datadir/pg_hba.conf <<EOF
  16. local all $USER trust
  17. host template1 $USER 127.0.0.1/32 trust
  18. host $USER $USER 127.0.0.1/32 trust
  19. host epgsql_test_db1 $USER 127.0.0.1/32 trust
  20. host epgsql_test_db1 epgsql_test 127.0.0.1/32 trust
  21. host epgsql_test_db1 epgsql_test_md5 127.0.0.1/32 md5
  22. host epgsql_test_db1 epgsql_test_cleartext 127.0.0.1/32 password
  23. hostssl epgsql_test_db1 epgsql_test_cert 127.0.0.1/32 cert
  24. EOF