Commit f5b558c3 authored by iSergio's avatar iSergio
Browse files

Add configure pgpool by categories

parent 49f081cd
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -19,14 +19,14 @@ TYPE=primary
VERBOSE=false
CATEGORY=a

usage="$(basename "$0") [-h] [-p] [-s] [-a|b|c]-- Script configure pgpool-II
usage="$(basename "$0") [-h] [-p] [-s] [-a|b]-- Script configure pgpool-II
 where:
     -h  show this help text and exit
     -p  configure pgpool as primary
     -s  configure pgpool as standby
     -a  configure pgpool for category A
     -b  configure pgpool for category B
     -c  configure pgpool for category C"
     -a  configure pgpool for category A (4 servers) (separate jboss and postgresql clusters) (Default: a)
     -b  configure pgpool for category B (2 servers) (jboss and postgresql cluster on same hasts) (Default: a)
"

while getopts ':psvh' option; do
    case "$option" in
@@ -40,8 +40,6 @@ while getopts ':psvh' option; do
            ;;
        b) CATEGORY=b
            ;;
        c) CATEGORY=c
            ;;
        h) echo "$usage"
            exit
            ;;
@@ -56,6 +54,12 @@ read -r -p "For which server will be configured PgPool-II(primary | standby) (De
if [[ ! -z $_TYPE ]]; then
    TYPE=$_TYPE
fi

if [[ "$CATEGORY" == "a" ]]; then
    PGPOOL_PRIMARY_HOST=$JBOSS_PRIMARY_HOST
    PGPOOL_STANDBY_HOST=$JBOSS_STANDBY_HOST
fi

read -r -p "PgPool primary host (Default: $PGPOOL_PRIMARY_HOST):" _PGPOOL_PRIMARY_HOST
if [[ ! -z $_PGPOOL_PRIMARY_HOST ]]; then
    PGPOOL_PRIMARY_HOST=$_PGPOOL_PRIMARY_HOST
@@ -91,6 +95,18 @@ sed -i 's/__PGPOOL_TRUSTED_SERVERS__/'$PGPOOL_TRUSTED_SERVERS'/g' $PGPOOL_CONFIG
sed -i 's/__PGPOOL_DELEGATE_IP__/'$PGPOOL_DELEGATE_IP'/g' $PGPOOL_CONFIG
sed -i 's/__PGPOOL_INTERFACE__/'$PGPOOL_INTERFACE'/g' $PGPOOL_CONFIG

if [[ "$CATEGORY" == "a" ]]; then
    sed -i 's/PGPOOLUSER=postgres/PGPOOLUSER=root/g' /etc/init.d/pgpool
    sed -i 's/socket_dir = '\''\/var\/pgtmp'\''/socket_dir = '\''\/var\/tmp'\''/g' $PGPOOL_CONFIG
    sed -i 's/load_balance_mode = on/load_balance_mode = off/g' $PGPOOL_CONFIG
    sed -i 's/master_slave_mode = on/master_slave_mode = off/g' $PGPOOL_CONFIG
    sed -i '/^backend_hostname/s/^/#/' $PGPOOL_CONFIG
    sed -i '/^backend_port/s/^/#/' $PGPOOL_CONFIG
    sed -i '/^backend_weight/s/^/#' $PGPOOL_CONFIG
    sed -i '/^backend_data_directory/s/^/#' $PGPOOL_CONFIG
    sed -i '/^backend_flag/s/^/#' $PGPOOL_CONFIG
fi

echo "postgres:"`pg_md5 postgres` >> $PGPOOL_DIR/pcp.conf

chmod 4755 /sbin/ifconfig