create.sh 930 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. #move to script directory so all relative paths work
  3. cd "$(dirname "$0")"
  4. #includes
  5. . ../config.sh
  6. #set the working directory
  7. cwd=$(pwd)
  8. cd /tmp
  9. #set client encoding
  10. sudo -u postgres psql -c "SET client_encoding = 'UTF8';";
  11. #add the database users and databases
  12. sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
  13. sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
  14. #add the users and grant permissions
  15. sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$database_password';"
  16. sudo -u postgres psql -c "CREATE ROLE freeswitch WITH SUPERUSER LOGIN PASSWORD '$database_password';"
  17. sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE fusionpbx to fusionpbx;"
  18. sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
  19. sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
  20. #restart postgres
  21. service postgresql restart