From afd525e039daa84aa1ef5dbf8b252f2b3ee3ccfc Mon Sep 17 00:00:00 2001 From: iSergio Date: Fri, 23 Mar 2018 10:37:55 +0300 Subject: [PATCH] Fixes --- postgres/bin/pg_failover | 23 +++++++++++------------ postgres/bin/pg_recovery | 10 ++++++++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/postgres/bin/pg_failover b/postgres/bin/pg_failover index 362a0c1..3d05013 100755 --- a/postgres/bin/pg_failover +++ b/postgres/bin/pg_failover @@ -12,18 +12,17 @@ NEW_MASTER_DATA=${10} TRIGGER_FILE=${11} -printf "[DEBUG] -Node id: %d -Host name: %s -Port number: %d -Database cluster path: %s -New master node id: %d -Host name of the new master node: %s -Old master node id: %d -Old primary node id: %d -New master port number: %d -New master database cluster path: %s -Trigger file: %s\n" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" +printf "[DEBUG] Node id: %d +[DEBUG] Host name: %s +[DEBUG] Port number: %d +[DEBUG] Database cluster path: %s +[DEBUG] New master node id: %d +[DEBUG] Host name of the new master node: %s +[DEBUG] Old master node id: %d +[DEBUG] Old primary node id: %d +[DEBUG] New master port number: %d +[DEBUG] New master database cluster path: %s +[DEBUG] Trigger file: %s\n" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}" "${11}" if [ $NEW_MASTER_NODE_ID == $OLD_PRIMARY_NODE_ID ]; then echo "[INFO] Standby node is down. Failover not triggered!" diff --git a/postgres/bin/pg_recovery b/postgres/bin/pg_recovery index 827aa04..88addf1 100755 --- a/postgres/bin/pg_recovery +++ b/postgres/bin/pg_recovery @@ -29,8 +29,14 @@ function recovery () { echo "[DEBUG]: Standby host: $STANDBY_HOST" if [[ $PRIMARY_HOST == $STANDBY_HOST ]]; then - echo "Somthing wrong with primary and standby host defined in configs. Can't continue recovery." - exit 1 + if [[ $# != 2 ]]; then + echo "Something wrong with primary and standby host defined in configs. Can't continue recovery." + echo "Try execute script with parameters: example - pg_recovery ip_master id_slave" + exit 1 + else + PRIMARY_HOST=$1 + STANDBY_HOST=$2 + fi fi # Stop primary database (not necessary(check)) -- GitLab