recovery: make cluster power console self-contained
This commit is contained in:
parent
aa447e6996
commit
b7f6317fd2
@ -8,8 +8,8 @@ Usage:
|
|||||||
|
|
||||||
Purpose:
|
Purpose:
|
||||||
Friendly manual entrypoint for running cluster power recovery from a remote console.
|
Friendly manual entrypoint for running cluster power recovery from a remote console.
|
||||||
If the repo checkout exists locally, run the recovery script here.
|
Prefer a sibling cluster_power_recovery.sh when installed as a standalone helper.
|
||||||
Otherwise, delegate to another host that has the repo checkout.
|
Otherwise use a repo checkout if available, or delegate to another host.
|
||||||
|
|
||||||
Defaults:
|
Defaults:
|
||||||
--repo-dir $HOME/Development/titan-iac
|
--repo-dir $HOME/Development/titan-iac
|
||||||
@ -22,6 +22,7 @@ Examples:
|
|||||||
USAGE
|
USAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
REPO_DIR="${HOME}/Development/titan-iac"
|
REPO_DIR="${HOME}/Development/titan-iac"
|
||||||
DELEGATE_HOST="titan-24"
|
DELEGATE_HOST="titan-24"
|
||||||
|
|
||||||
@ -50,19 +51,37 @@ if [[ $# -lt 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LOCAL_SCRIPT="${REPO_DIR}/scripts/cluster_power_recovery.sh"
|
SIBLING_SCRIPT="${SCRIPT_DIR}/cluster_power_recovery.sh"
|
||||||
|
REPO_SCRIPT="${REPO_DIR}/scripts/cluster_power_recovery.sh"
|
||||||
|
LOCAL_SCRIPT=""
|
||||||
|
|
||||||
if [[ -x "${LOCAL_SCRIPT}" ]] && command -v kubectl >/dev/null 2>&1; then
|
if [[ -x "${SIBLING_SCRIPT}" ]]; then
|
||||||
|
LOCAL_SCRIPT="${SIBLING_SCRIPT}"
|
||||||
|
elif [[ -x "${REPO_SCRIPT}" ]]; then
|
||||||
|
LOCAL_SCRIPT="${REPO_SCRIPT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${LOCAL_SCRIPT}" ]] && command -v kubectl >/dev/null 2>&1; then
|
||||||
exec "${LOCAL_SCRIPT}" "$@"
|
exec "${LOCAL_SCRIPT}" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${DELEGATE_HOST}" ]]; then
|
if [[ -z "${DELEGATE_HOST}" ]]; then
|
||||||
echo "cluster-power-console: local repo checkout not found at ${REPO_DIR} and no delegate host configured" >&2
|
echo "cluster-power-console: no usable local recovery script found and no delegate host configured" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
quoted_repo_dir="$(printf '%q' "${REPO_DIR}")"
|
|
||||||
quoted_args="$(printf '%q ' "$@")"
|
quoted_args="$(printf '%q ' "$@")"
|
||||||
|
|
||||||
|
if [[ -r "${SIBLING_SCRIPT}" ]]; then
|
||||||
|
exec ssh -o BatchMode=yes -o ConnectTimeout=8 "${DELEGATE_HOST}" \
|
||||||
|
"bash -s -- ${quoted_args}" < "${SIBLING_SCRIPT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -r "${REPO_SCRIPT}" ]]; then
|
||||||
|
exec ssh -o BatchMode=yes -o ConnectTimeout=8 "${DELEGATE_HOST}" \
|
||||||
|
"bash -s -- ${quoted_args}" < "${REPO_SCRIPT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
quoted_repo_dir="$(printf '%q' "${REPO_DIR}")"
|
||||||
exec ssh -o BatchMode=yes -o ConnectTimeout=8 "${DELEGATE_HOST}" \
|
exec ssh -o BatchMode=yes -o ConnectTimeout=8 "${DELEGATE_HOST}" \
|
||||||
"cd ${quoted_repo_dir} && ./scripts/cluster_power_recovery.sh ${quoted_args}"
|
"cd ${quoted_repo_dir} && ./scripts/cluster_power_recovery.sh ${quoted_args}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user