setup_test_db.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. lc_messages = 'en_US.UTF-8'
  13. wal_level = 'logical'
  14. max_replication_slots = 15
  15. max_wal_senders = 15
  16. EOF
  17. cp test/data/epgsql.crt datadir/server.crt
  18. cp test/data/epgsql.key datadir/server.key
  19. cp test/data/root.crt datadir/root.crt
  20. cp test/data/root.key datadir/root.key
  21. chmod 0600 datadir/server.key
  22. cat > datadir/pg_hba.conf <<EOF
  23. local all $USER trust
  24. host template1 $USER 127.0.0.1/32 trust
  25. host $USER $USER 127.0.0.1/32 trust
  26. host epgsql_test_db1 $USER 127.0.0.1/32 trust
  27. host epgsql_test_db1 epgsql_test 127.0.0.1/32 trust
  28. host epgsql_test_db1 epgsql_test_md5 127.0.0.1/32 md5
  29. host epgsql_test_db1 epgsql_test_cleartext 127.0.0.1/32 password
  30. hostssl epgsql_test_db1 epgsql_test_cert 127.0.0.1/32 cert clientcert=1
  31. host replication epgsql_test_replication 127.0.0.1/32 trust
  32. EOF