#!/bin/sh
# Exit 0 if the keepalived configuration hands its state transitions to
# keepalived-notify.sh -- the script that writes /run/keepalived.state.
#
# Used by run (which message to log) and by data/check (whether the state
# file is REQUIRED for readiness). Both must decide the same way, hence one
# place.
#
# Only a line that starts with a notify keyword (notify, notify_master,
# notify_backup, ...) and names .../keepalived-notify.sh counts, quoted or not;
# a comment does not. Searched is /etc/keepalived recursively: keepalived.conf
# and the files it includes from there. Puppet (profiles::keepalived) renders
# "notify /usr/sbin/keepalived-notify.sh" into the vrrp_sync_group.
#
# Override for a configuration elsewhere: KEEPALIVED_CONF_DIR.

dir=${KEEPALIVED_CONF_DIR:-/etc/keepalived}
grep -rqsE '^[[:space:]]*notify[a-z_]*[[:space:]]+"?[^"[:space:]]*/keepalived-notify[.]sh"?([[:space:]]|$)' "$dir"
