Files
fusionpbx-install.sh/debian/resources/postgresql/create.sh
T

32 lines
1.1 KiB
Bash
Raw Normal View History

2017-11-20 22:00:40 -07:00
#!/bin/sh
#move to script directory so all relative paths work
cd "$(dirname "$0")"
#includes
. ../config.sh
#set the working directory
cwd=$(pwd)
cd /tmp
#set client encoding
2018-10-25 10:47:59 -06:00
sudo -u postgres psql -p $database_port -c "SET client_encoding = 'UTF8';";
2017-11-20 22:00:40 -07:00
#add the database users and databases
2018-10-25 10:47:59 -06:00
sudo -u postgres psql -p $database_port -c "CREATE DATABASE fusionpbx;";
sudo -u postgres psql -p $database_port -c "CREATE DATABASE freeswitch;";
2017-11-20 22:00:40 -07:00
#add the users and grant permissions
2018-10-25 10:47:59 -06:00
sudo -u postgres psql -p $database_port -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$database_password';"
sudo -u postgres psql -p $database_port -c "CREATE ROLE freeswitch WITH SUPERUSER LOGIN PASSWORD '$database_password';"
sudo -u postgres psql -p $database_port -c "GRANT ALL PRIVILEGES ON DATABASE fusionpbx to fusionpbx;"
sudo -u postgres psql -p $database_port -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
sudo -u postgres psql -p $database_port -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
2017-11-20 22:00:40 -07:00
2022-01-15 18:56:22 -07:00
#reload the config
sudo -u postgres psql -p $database_port -c "SELECT pg_reload_conf();"
2017-11-20 22:00:40 -07:00
#restart postgres
2022-01-15 18:56:22 -07:00
#systemctl restart postgresql