.travis.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. set -eu
  3. client_configure() {
  4. sudo chmod 600 $PQSSLCERTTEST_PATH/postgresql.key
  5. }
  6. pgdg_repository() {
  7. local sourcelist='sources.list.d/postgresql.list'
  8. curl -sS 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' | sudo apt-key add -
  9. echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION | sudo tee "/etc/apt/$sourcelist"
  10. sudo apt-get -o Dir::Etc::sourcelist="$sourcelist" -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' update
  11. }
  12. postgresql_configure() {
  13. sudo tee /etc/postgresql/$PGVERSION/main/pg_hba.conf > /dev/null <<-config
  14. local all all trust
  15. hostnossl all pqgossltest 127.0.0.1/32 reject
  16. hostnossl all pqgosslcert 127.0.0.1/32 reject
  17. hostssl all pqgossltest 127.0.0.1/32 trust
  18. hostssl all pqgosslcert 127.0.0.1/32 cert
  19. host all all 127.0.0.1/32 trust
  20. hostnossl all pqgossltest ::1/128 reject
  21. hostnossl all pqgosslcert ::1/128 reject
  22. hostssl all pqgossltest ::1/128 trust
  23. hostssl all pqgosslcert ::1/128 cert
  24. host all all ::1/128 trust
  25. config
  26. xargs sudo install -o postgres -g postgres -m 600 -t /var/lib/postgresql/$PGVERSION/main/ <<-certificates
  27. certs/root.crt
  28. certs/server.crt
  29. certs/server.key
  30. certificates
  31. sort -VCu <<-versions ||
  32. $PGVERSION
  33. 9.2
  34. versions
  35. sudo tee -a /etc/postgresql/$PGVERSION/main/postgresql.conf > /dev/null <<-config
  36. ssl_ca_file = 'root.crt'
  37. ssl_cert_file = 'server.crt'
  38. ssl_key_file = 'server.key'
  39. config
  40. echo 127.0.0.1 postgres | sudo tee -a /etc/hosts > /dev/null
  41. sudo service postgresql restart
  42. }
  43. postgresql_install() {
  44. xargs sudo apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew' install <<-packages
  45. postgresql-$PGVERSION
  46. postgresql-server-dev-$PGVERSION
  47. postgresql-contrib-$PGVERSION
  48. packages
  49. }
  50. postgresql_uninstall() {
  51. sudo service postgresql stop
  52. xargs sudo apt-get -y --purge remove <<-packages
  53. libpq-dev
  54. libpq5
  55. postgresql
  56. postgresql-client-common
  57. postgresql-common
  58. packages
  59. sudo rm -rf /var/lib/postgresql
  60. }
  61. megacheck_install() {
  62. # Lock megacheck version at $MEGACHECK_VERSION to prevent spontaneous
  63. # new error messages in old code.
  64. go get -d honnef.co/go/tools/...
  65. git -C $GOPATH/src/honnef.co/go/tools/ checkout $MEGACHECK_VERSION
  66. go install honnef.co/go/tools/cmd/megacheck
  67. megacheck --version
  68. }
  69. golint_install() {
  70. go get golang.org/x/lint/golint
  71. }
  72. $1