Update postgresql.sh
This commit is contained in:
parent
72d486560d
commit
9b40c12126
|
|
@ -19,7 +19,11 @@ echo "Install PostgreSQL and create the database and users\n"
|
||||||
|
|
||||||
#included in the distribution
|
#included in the distribution
|
||||||
if [ ."$database_repo" = ."system" ]; then
|
if [ ."$database_repo" = ."system" ]; then
|
||||||
|
if [ ."$database_host" != "127.0.0.1" && ."$database_host" != "::1"] ; then
|
||||||
apt-get install -y sudo postgresql
|
apt-get install -y sudo postgresql
|
||||||
|
else
|
||||||
|
apt-get install -y sudo postgresql-client
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#postgres official repository
|
#postgres official repository
|
||||||
|
|
@ -38,6 +42,7 @@ if [ ."$database_repo" = ."official" ]; then
|
||||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/postgresql.list
|
echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/postgresql.list
|
||||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||||
fi
|
fi
|
||||||
|
if [ ."$database_host" != "127.0.0.1" && ."$database_host" != "::1"] ; then
|
||||||
if [ ."$database_version" = ."latest" ]; then
|
if [ ."$database_version" = ."latest" ]; then
|
||||||
apt-get install -y sudo postgresql
|
apt-get install -y sudo postgresql
|
||||||
fi
|
fi
|
||||||
|
|
@ -47,10 +52,14 @@ if [ ."$database_repo" = ."official" ]; then
|
||||||
if [ ."$database_version" = ."9.4" ]; then
|
if [ ."$database_version" = ."9.4" ]; then
|
||||||
apt-get install -y sudo postgresql-$database_version
|
apt-get install -y sudo postgresql-$database_version
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
apt-get install -y sudo postgresql-client
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#add PostgreSQL and 2ndquadrant repos
|
#add PostgreSQL and 2ndquadrant repos
|
||||||
if [ ."$database_repo" = ."2ndquadrant" ]; then
|
if [ ."$database_repo" = ."2ndquadrant" ]; then
|
||||||
|
if [ ."$database_host" != "127.0.0.1" && ."$database_host" != "::1"] ; then
|
||||||
apt install -y curl
|
apt install -y curl
|
||||||
curl https://dl.2ndquadrant.com/default/release/get/deb | bash
|
curl https://dl.2ndquadrant.com/default/release/get/deb | bash
|
||||||
if [ ."$os_codename" = ."buster" ]; then
|
if [ ."$os_codename" = ."buster" ]; then
|
||||||
|
|
@ -58,11 +67,14 @@ if [ ."$database_repo" = ."2ndquadrant" ]; then
|
||||||
fi
|
fi
|
||||||
apt update
|
apt update
|
||||||
apt-get install -y sudo postgresql-bdr-9.4 postgresql-bdr-9.4-bdr-plugin postgresql-bdr-contrib-9.4
|
apt-get install -y sudo postgresql-bdr-9.4 postgresql-bdr-9.4-bdr-plugin postgresql-bdr-contrib-9.4
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#systemd
|
#systemd
|
||||||
systemctl daemon-reload
|
if [ ."$database_host" != "127.0.0.1" && ."$database_host" != "::1"] ; then
|
||||||
systemctl restart postgresql
|
systemctl daemon-reload
|
||||||
|
systemctl restart postgresql
|
||||||
|
fi
|
||||||
|
|
||||||
#init.d
|
#init.d
|
||||||
#/usr/sbin/service postgresql restart
|
#/usr/sbin/service postgresql restart
|
||||||
|
|
@ -79,15 +91,18 @@ systemctl restart postgresql
|
||||||
cwd=$(pwd)
|
cwd=$(pwd)
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
|
||||||
#add the databases, users and grant permissions to them
|
if [ ."$database_host" != "127.0.0.1" && ."$database_host" != "::1"] ; then
|
||||||
sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
|
# add the databases, users and grant permissions to them
|
||||||
sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
|
sudo -u postgres psql -c "CREATE DATABASE fusionpbx;";
|
||||||
sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$password';"
|
sudo -u postgres psql -c "CREATE DATABASE freeswitch;";
|
||||||
sudo -u postgres psql -c "CREATE ROLE freeswitch WITH SUPERUSER LOGIN PASSWORD '$password';"
|
sudo -u postgres psql -c "CREATE ROLE fusionpbx WITH SUPERUSER LOGIN PASSWORD '$password';"
|
||||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE fusionpbx to fusionpbx;"
|
sudo -u postgres psql -c "CREATE ROLE freeswitch WITH SUPERUSER LOGIN PASSWORD '$password';"
|
||||||
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
|
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 freeswitch;"
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to fusionpbx;"
|
||||||
#ALTER USER fusionpbx WITH PASSWORD 'newpassword';
|
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;"
|
||||||
|
# ALTER USER fusionpbx WITH PASSWORD 'newpassword';
|
||||||
|
fi
|
||||||
|
|
||||||
cd $cwd
|
cd $cwd
|
||||||
|
|
||||||
#set the ip address
|
#set the ip address
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue