Update: separate ipv4 and ipv6 ip address
set back to the original indentation
This commit is contained in:
parent
3ed7aba975
commit
db7b878426
|
|
@ -24,21 +24,21 @@ read -p "Enter the replication method. (logical,bdr): " replication_method
|
||||||
|
|
||||||
#request group_create, node_1 and node_2
|
#request group_create, node_1 and node_2
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
read -p 'Create Group (y,n): ' group_create
|
read -p 'Create Group (y,n): ' group_create
|
||||||
if [ .$group_create = ."y" ]; then
|
if [ .$group_create = ."y" ]; then
|
||||||
read -p 'Enter this Nodes Address: ' node_1;
|
read -p 'Enter this Nodes Address: ' node_1;
|
||||||
else
|
else
|
||||||
read -p 'Join using node already in group: ' node_1;
|
read -p 'Join using node already in group: ' node_1;
|
||||||
read -p 'Enter this Nodes Address: ' node_2;
|
read -p 'Enter this Nodes Address: ' node_2;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
#determine which database to replicate
|
#determine which database to replicate
|
||||||
read -p 'Replicate the FusionPBX Database (y,n): ' system_replicate
|
read -p 'Replicate the FusionPBX Database (y,n): ' system_replicate
|
||||||
|
|
||||||
#determine which database to replicate
|
#determine which database to replicate
|
||||||
read -p 'Replicate the FreeSWITCH Database (y,n): ' switch_replicate
|
read -p 'Replicate the FreeSWITCH Database (y,n): ' switch_replicate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#determine whether to add iptable rules
|
#determine whether to add iptable rules
|
||||||
|
|
@ -50,37 +50,37 @@ echo " Summary";
|
||||||
echo "-----------------------------";
|
echo "-----------------------------";
|
||||||
echo "All Node IP Addresses: $nodes";
|
echo "All Node IP Addresses: $nodes";
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
echo "Create Group: $group_create";
|
echo "Create Group: $group_create";
|
||||||
if [ .$group_create = ."y" ]; then
|
if [ .$group_create = ."y" ]; then
|
||||||
echo "This Nodes Address: $node_1";
|
echo "This Nodes Address: $node_1";
|
||||||
else
|
else
|
||||||
echo "Join using node in group: $node_1";
|
echo "Join using node in group: $node_1";
|
||||||
echo "This Node Address: $node_2";
|
echo "This Node Address: $node_2";
|
||||||
fi
|
fi
|
||||||
echo "Replicate the FusionPBX Database: $system_replicate";
|
echo "Replicate the FusionPBX Database: $system_replicate";
|
||||||
echo "Replicate the FreeSWITCH Database: $switch_replicate";
|
echo "Replicate the FreeSWITCH Database: $switch_replicate";
|
||||||
fi
|
fi
|
||||||
echo "Add iptable rules: $iptables_add";
|
echo "Add iptable rules: $iptables_add";
|
||||||
echo "";
|
echo "";
|
||||||
|
|
||||||
#verify
|
#verify
|
||||||
read -p 'Is the information correct (y,n): ' verified
|
read -p 'Is the information correct (y,n): ' verified
|
||||||
if [ .$verified != ."y" ]; then
|
if [ .$verified != ."y" ]; then
|
||||||
echo "Goodbye";
|
echo "Goodbye";
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#iptables rules
|
#iptables rules
|
||||||
if [ .$iptables_add = ."y" ]; then
|
if [ .$iptables_add = ."y" ]; then
|
||||||
for node in $nodes; do
|
for node in $nodes; do
|
||||||
/usr/sbin/iptables -A INPUT -j ACCEPT -p tcp --dport 5432 -s ${node}/32
|
/usr/sbin/iptables -A INPUT -j ACCEPT -p tcp --dport 5432 -s ${node}/32
|
||||||
/usr/sbin/iptables -A INPUT -j ACCEPT -p tcp --dport 22000 -s ${node}/32
|
/usr/sbin/iptables -A INPUT -j ACCEPT -p tcp --dport 22000 -s ${node}/32
|
||||||
done
|
done
|
||||||
apt-get remove iptables-persistent -y
|
apt-get remove iptables-persistent -y
|
||||||
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections
|
echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections
|
||||||
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections
|
echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections
|
||||||
apt-get install -y iptables-persistent
|
apt-get install -y iptables-persistent
|
||||||
systemctl restart fail2ban
|
systemctl restart fail2ban
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#setup ssl
|
#setup ssl
|
||||||
|
|
@ -101,7 +101,7 @@ echo "max_wal_senders = 10" >> /etc/postgresql/$database_version/main/postgresql
|
||||||
echo "max_replication_slots = 48" >> /etc/postgresql/$database_version/main/postgresql.conf
|
echo "max_replication_slots = 48" >> /etc/postgresql/$database_version/main/postgresql.conf
|
||||||
echo "max_worker_processes = 48" >> /etc/postgresql/$database_version/main/postgresql.conf
|
echo "max_worker_processes = 48" >> /etc/postgresql/$database_version/main/postgresql.conf
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
echo "shared_preload_libraries = 'bdr'" >> /etc/postgresql/$database_version/main/postgresql.conf
|
echo "shared_preload_libraries = 'bdr'" >> /etc/postgresql/$database_version/main/postgresql.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#pg_hba.conf - append settings
|
#pg_hba.conf - append settings
|
||||||
|
|
@ -133,58 +133,58 @@ cd /tmp
|
||||||
|
|
||||||
#add the bdr repo
|
#add the bdr repo
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
if [ .$database_version = ."9.6" ]; then
|
if [ .$database_version = ."9.6" ]; then
|
||||||
echo 'deb http://packages.2ndquadrant.com/bdr/apt/ jessie-2ndquadrant main' > /etc/apt/sources.list.d/2ndquadrant.list
|
echo 'deb http://packages.2ndquadrant.com/bdr/apt/ jessie-2ndquadrant main' > /etc/apt/sources.list.d/2ndquadrant.list
|
||||||
/usr/bin/wget --quiet -O - http://packages.2ndquadrant.com/bdr/apt/AA7A6805.asc | apt-key add -
|
/usr/bin/wget --quiet -O - http://packages.2ndquadrant.com/bdr/apt/AA7A6805.asc | apt-key add -
|
||||||
apt-get update && apt-get upgrade -y
|
apt-get update && apt-get upgrade -y
|
||||||
apt-get install -y sudo postgresql-9.6-bdr-plugin
|
apt-get install -y sudo postgresql-9.6-bdr-plugin
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#add the postgres extensions
|
#add the postgres extensions
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
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;";
|
||||||
sudo -u postgres psql -d freeswitch -c "CREATE EXTENSION btree_gist;";
|
sudo -u postgres psql -d freeswitch -c "CREATE EXTENSION btree_gist;";
|
||||||
sudo -u postgres psql -d freeswitch -c "CREATE EXTENSION bdr;";
|
sudo -u postgres psql -d freeswitch -c "CREATE EXTENSION bdr;";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#add master nodes
|
#add master nodes
|
||||||
if [ .$replication_method = ."bdr" ]; then
|
if [ .$replication_method = ."bdr" ]; then
|
||||||
if [ .$group_create = ."y" ]; then
|
if [ .$group_create = ."y" ]; then
|
||||||
#add first node
|
#add first node
|
||||||
if [ .$system_replicate = ."y" ]; then
|
if [ .$system_replicate = ."y" ]; then
|
||||||
sudo -u postgres psql -d fusionpbx -c "SELECT bdr.bdr_group_create(local_node_name := '$node_1', node_external_dsn := 'host=$node_1 port=5432 dbname=fusionpbx connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
sudo -u postgres psql -d fusionpbx -c "SELECT bdr.bdr_group_create(local_node_name := '$node_1', node_external_dsn := 'host=$node_1 port=5432 dbname=fusionpbx connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
||||||
fi
|
fi
|
||||||
if [ .$switch_replicate = ."y" ]; then
|
if [ .$switch_replicate = ."y" ]; then
|
||||||
sudo -u postgres psql -d freeswitch -c "SELECT bdr.bdr_group_create(local_node_name := '$node_1', node_external_dsn := 'host=$node_1 port=5432 dbname=freeswitch connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
sudo -u postgres psql -d freeswitch -c "SELECT bdr.bdr_group_create(local_node_name := '$node_1', node_external_dsn := 'host=$node_1 port=5432 dbname=freeswitch connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
#add additional master nodes
|
#add additional master nodes
|
||||||
if [ .$system_replicate = ."y" ]; then
|
if [ .$system_replicate = ."y" ]; then
|
||||||
sudo -u postgres psql -d fusionpbx -c "SELECT bdr.bdr_group_join(local_node_name := '$node_2', node_external_dsn := 'host=$node_2 port=5432 dbname=fusionpbx connect_timeout=10 keepalives_idle=5 keepalives_interval=1', join_using_dsn := 'host=$node_1 port=5432 dbname=fusionpbx connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
sudo -u postgres psql -d fusionpbx -c "SELECT bdr.bdr_group_join(local_node_name := '$node_2', node_external_dsn := 'host=$node_2 port=5432 dbname=fusionpbx connect_timeout=10 keepalives_idle=5 keepalives_interval=1', join_using_dsn := 'host=$node_1 port=5432 dbname=fusionpbx connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
||||||
fi
|
fi
|
||||||
if [ .$switch_replicate = ."y" ]; then
|
if [ .$switch_replicate = ."y" ]; then
|
||||||
sudo -u postgres psql -d freeswitch -c "SELECT bdr.bdr_group_join(local_node_name := '$node_2', node_external_dsn := 'host=$node_2 port=5432 dbname=freeswitch connect_timeout=10 keepalives_idle=5 keepalives_interval=1', join_using_dsn := 'host=$node_1 port=5432 dbname=freeswitch connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
sudo -u postgres psql -d freeswitch -c "SELECT bdr.bdr_group_join(local_node_name := '$node_2', node_external_dsn := 'host=$node_2 port=5432 dbname=freeswitch connect_timeout=10 keepalives_idle=5 keepalives_interval=1', join_using_dsn := 'host=$node_1 port=5432 dbname=freeswitch connect_timeout=10 keepalives_idle=5 keepalives_interval=1 sslmode=require');";
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#load the freeswitch database
|
#load the freeswitch database
|
||||||
#sudo -u postgres psql -d freeswitch -f /var/www/fusionpbx/resources/install/sql/switch.sql -L /tmp/switch-sql.log
|
#sudo -u postgres psql -d freeswitch -f /var/www/fusionpbx/resources/install/sql/switch.sql -L /tmp/switch-sql.log
|
||||||
|
|
||||||
#sleeping
|
#sleeping
|
||||||
if [ .$group_create = ."n" ]; then
|
if [ .$group_create = ."n" ]; then
|
||||||
echo "Sleeping for 15 seconds";
|
echo "Sleeping for 15 seconds";
|
||||||
for i in `seq 1 15`; do
|
for i in `seq 1 15`; do
|
||||||
echo $i
|
echo $i
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#add extension pgcrypto
|
#add extension pgcrypto
|
||||||
if [ .$group_create = ."n" ]; then
|
if [ .$group_create = ."n" ]; then
|
||||||
sudo -u postgres psql -d freeswitch -c "CREATE EXTENSION pgcrypto;";
|
sudo -u postgres psql -d freeswitch -c "CREATE EXTENSION pgcrypto;";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#message to user
|
#message to user
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue