run.sh 452 B

12345678910111213141516171819
  1. #!/bin/bash
  2. mkdir data
  3. pg_dump -d grocery -Ft -f dump
  4. podman-compose -p grocery up -d
  5. podman exec -i grocery_db_1 psql -U postgres -b < <( cat <<EOF
  6. CREATE ROLE pi;
  7. ALTER ROLE pi LOGIN;
  8. CREATE ROLE das;
  9. CREATE ROLE grocery_ro;
  10. ALTER ROLE grocery_ro LOGIN;
  11. GRANT das TO pi;
  12. EOF
  13. )
  14. podman exec -i grocery_db_1 pg_restore -U postgres -Ce --dbname postgres < dump
  15. sudo cp pg_hba.conf data/pg_hba.conf
  16. podman exec -i grocery_db_1 bash -c 'kill -HUP 1'