#!/bin/bash master=( {% for notify in keepalived__notify_master %} {{ notify | quote }} {% endfor %} ) backup=( {% for notify in keepalived__notify_backup %} {{ notify | quote }} {% endfor %} ) fault=( {% for notify in keepalived__notify_fault %} {{ notify | quote }} {% endfor %} ) case "$1" in master | backup | fault) scripts="$1[@]" ;; *) echo "Usage: $0 (master|backup|fault)" >&2 exit 1 esac for script in "${!scripts}" do eval "${script}" done