Fediversity/deployment/run/tf-proxmox-vm/await-ssh.sh
Kiara Grouwstra b8a1ce5b74
rename deployment method to prep for separation
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
2025-10-22 15:31:40 +02:00

31 lines
603 B
Bash

#! /usr/bin/env bash
set -euo pipefail
declare username host key_file ssh_opts
readarray -t ssh_opts < <(echo "$ssh_opts" | jq -r '.[]')
sshOpts=(
-o BatchMode=yes \
-o StrictHostKeyChecking=no \
-o ConnectTimeout=5 \
-o ServerAliveInterval=5 \
)
if [[ -n "${key_file}" ]]; then
sshOpts+=(
-i "${key_file}"
)
fi
for ssh_opt in "${ssh_opts[@]}"; do
sshOpts+=(
-o "${ssh_opt}"
)
done
for i in $(seq 1 30); do
if ssh "${sshOpts[@]}" "${username}@${host}" "true"; then
exit 0
fi
echo "Waiting for SSH (attempt #$i)..."
sleep 5
done
echo "SSH never came up!" >&2
exit 1