test commit for Master.conf and common.sh updates

This commit is contained in:
2026-03-24 00:50:01 +00:00
parent 8a2fa81c40
commit 60a86e42d7
2 changed files with 18 additions and 9 deletions
+12 -2
View File
@@ -24,6 +24,7 @@ load_master_conf() {
local master_conf="$script_dir/../Master.conf"
if [ -f "$master_conf" ]; then
# shellcheck source=/dev/null
source "$master_conf"
echo "Loaded Master.conf from $master_conf"
else
@@ -79,8 +80,16 @@ require_var() {
fi
}
#-----------------------------------------------------------------------------------------------
# Host and Remote Detection
# Uses HOST1, HOST2, and SSH_KEYS from Master.conf
#-----------------------------------------------------------------------------------------------
detect_hosts() {
# Must load Master.conf first
require_var HOST1
require_var HOST2
require_var SSH_KEYS
LOCAL_HOSTNAME="$(hostname)"
if [[ "$LOCAL_HOSTNAME" == "$HOST1" ]]; then
@@ -97,14 +106,14 @@ detect_hosts() {
echo "Local server: $LOCAL_SERVER_NAME"
echo "Remote server: $REMOTE_SERVER_NAME"
# Resolve Tailscale IP dynamically
# Resolve remote Tailscale IP
REMOTE_SERVER=$(tailscale ip -4 "$REMOTE_SERVER_NAME" 2>/dev/null)
if [[ -z "$REMOTE_SERVER" ]]; then
echo "Error: Could not resolve Tailscale IP for $REMOTE_SERVER_NAME"
exit 1
fi
# Determine SSH Key
# Determine SSH key
KEY_ID="$LOCAL_SERVER_NAME|$REMOTE_SERVER_NAME"
if [[ -n "${SSH_KEYS[$KEY_ID]}" ]]; then
SSH_KEY="${SSH_KEYS[$KEY_ID]}"
@@ -112,5 +121,6 @@ detect_hosts() {
echo "Error: No SSH key defined for $LOCAL_SERVER_NAME$REMOTE_SERVER_NAME"
exit 1
fi
echo "Using SSH key: $SSH_KEY"
}