#!/bin/bash

# Run scripts in /etc/redis/trigger.d when Redis Sentinel notices
# configuration change.


set -o nounset -o pipefail -o errexit

master_name="${1}"
role="${2}"
state="${3}"
from_ip="${4}"
from_port="${5}"
to_ip="${6}"
to_port="${7}"

if [ -d /etc/redis/trigger.d ] ; then
    run-parts \
        --arg="${master_name}" \
        --arg="${role}" \
        --arg="${state}" \
        --arg="${from_ip}" \
        --arg="${from_port}" \
        --arg="${to_ip}" \
        --arg="${to_port}" \
        /etc/redis/trigger.d
fi
