Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. source /vagrant/scripts/functions.sh
  2. logger1 'Begin provisioner "install-scorr-postgres-database"...'
  3.  
  4. logger2 'Set Postgres user "postgres" password="postgres"'
  5. sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password '$POSTGRES_PASSWORD';"
  6.  
  7.  
  8. logger2 'DEPLOYING SCORR DATABASE BACKUP...'
  9. logger2 'Modify pg_hba.conf to allow pg_restore without password prompt'
  10. # Enable pg_restore without password
  11. # Change pg_hba.conf to:
  12. # host all all 127.0.0.1/32 trust
  13. sed -i.bak1 's/^\(host\s*all\s*all\s*127\.0\.0\.1\/32\s*\)md5/\1trust/g' /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf
  14.  
  15.  
  16. logger2 'Restarting postgres...'
  17. service postgresql restart
  18. logger2 'Waiting 10 seconds for postgres to restart'
  19. sleep 10
  20.  
  21.  
  22. logger2 'Create scorr database'
  23. createdb --username postgres --host localhost --port 5432 --owner postgres --echo scorr
  24.  
  25.  
  26. logger2 'Restore SCoRR database'
  27. sudo -u postgres pg_restore --username postgres --host localhost --port 5432 --dbname scorr --verbose /vagrant/$POSTGRES_SCORR_SQL_DUMP_FILE
  28.  
  29.  
  30. logger2 'Restore pg_hba.conf to original settings'
  31. # Restore pg_restore settings
  32. # Change pg_hba.conf to:
  33. # host all all 127.0.0.1/32 md5
  34. sed -i.bak2 's/^\(host\s*all\s*all\s*127\.0\.0\.1\/32\s*\)trust/\1md5/g' /etc/postgresql/$POSTGRES_VERSION/main/pg_hba.conf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement