#!/bin/bash check_controller() { controller=$1 model="cpe-focal" juju run-action -m "${controller}":${model} mysql-innodb-cluster/leader --wait cluster-status --format json | jq -rc '.[].results."cluster-status"' | jq } if [[ -z "$1" ]] ; then check_controller "$(juju controllers --format json | jq -r .\"current-controller\")" else check_controller "${1}" fi