Add creat role and permissions

This commit is contained in:
Mark J Crane
2017-03-30 21:41:35 +00:00
parent 7102bb4d0a
commit 99eeaa13cf

View File

@@ -9,6 +9,7 @@ cd "$(dirname "$0")"
#set the date #set the date
now=$(date +%Y-%m-%d) now=$(date +%Y-%m-%d)
#set the database password
if [ .$database_password = .'random' ]; then if [ .$database_password = .'random' ]; then
database_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g') database_password=$(dd if=/dev/urandom bs=1 count=20 2>/dev/null | base64 | sed 's/[=\+//]//g')
fi fi
@@ -94,6 +95,13 @@ cd /tmp
sudo -u postgres psql -c "CREATE DATABASE fusionpbx;"; sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
sudo -u postgres psql -c "CREATE DATABASE freeswitch;"; sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
#add the users and grant permissions
sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$database_password';"
sudo -u postgres psql -c "CREATE ROLE freeswitch WITH SUPERUSER LOGIN PASSWORD '$database_password';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE fusionpbx to fusionpbx;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
#add the postgres extensions #add the postgres extensions
sudo -u postgres psql -d fusionpbx -c "CREATE EXTENSION btree_gist;"; sudo -u postgres psql -d fusionpbx -c "CREATE EXTENSION btree_gist;";
sudo -u postgres psql -d fusionpbx -c "CREATE EXTENSION bdr;"; sudo -u postgres psql -d fusionpbx -c "CREATE EXTENSION bdr;";