#! /bin/sh
#get the property to be changed in the arguement
if [ $# -lt 3 ]; then
echo "Usage: $0 <property> <value> <secondary_ip> [dr ip]"
exit 1
fi
db_prop_name="$1"
db_prop_value="$2"
sec_node_ip="$3"
dr_node_ip=""
if [ $# -lt 4 ]; then
dr_node_ip="$4"
fi
#append it to the postgres.conf file
echo " Database property - value = $db_prop_name - $db_prop_value "
echo "$db_prop_name = '$db_prop_value' # allowed SSL ciphers" >> /var/mps/db_pgsql/data/postgresql.conf
#reload the db
su -l mpspostgres -c /mps/scripts/pgsql/reloadpgsql.sh
#delete retain_ciphers.conf if already exist
rm -f /mpsconfig/retain_ciphers.conf
#create a retain_ciphers.conf to retain this property when adm reboots
echo "$db_prop_name = '$db_prop_value' # allowed SSL ciphers" >> /mpsconfig/retain_ciphers.conf
#copy them to secondary node
su -l pgxl -c "rsync -t /mpsconfig/retain_ciphers.conf pgxl@$sec_node_ip:/mpsconfig/retain_ciphers.conf"
#copy them to dr node
if [ "$dr_node_ip" != "" ]; then
su -l mpspostgres -c "rsync -t /mpsconfig/retain_ciphers.conf pgxl@$dr_node_ip:/mpsconfig/retain_ciphers.conf"
fi