From 60a86e42d72a58a29725b58d2b5a6fbea7c60aae Mon Sep 17 00:00:00 2001 From: FailedProxy Date: Tue, 24 Mar 2026 00:50:01 +0000 Subject: [PATCH] test commit for Master.conf and common.sh updates --- Master.conf | 13 ++++++------- common.sh | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Master.conf b/Master.conf index 0c9cc05..4db225b 100644 --- a/Master.conf +++ b/Master.conf @@ -7,6 +7,11 @@ HOST1="unRAID-Gmer4Lfe" HOST2="unRAID-Jayred365" +# SSH Key Mapping (used for rsync scripts to determine which SSH key to use based on source and destination) +declare -A SSH_KEYS +SSH_KEYS["unRAID-Gmer4Lfe|unRAID-Jayred365"]="/root/.ssh/Gmer4Lfe-rsync-key" +SSH_KEYS["unRAID-Jayred365|unRAID-Gmer4Lfe"]="/root/.ssh/Jayred365-rsync-key" + #----------------------------------------------------------------------------------------------- #----------------- User Variables, Please adjust here in Master.conf as needed ----------------- #----------------------------------------------------------------------------------------------- @@ -106,10 +111,4 @@ PROFILE_EXCLUDE_DIRS["important-data"]="logs *.tmp" PROFILE_EXCLUDE_DIRS["emby"]="logs *.tmp" #----------------------------------------------------------------------------------------------- #---------------End Of User Variables, Please adjust here in Master.conf as needed ------------- -#----------------------------------------------------------------------------------------------- - - -# SSH Key Mapping (used for rsync scripts to determine which SSH key to use based on source and destination) -declare -A SSH_KEYS -SSH_KEYS["unRAID-Gmer4Lfe|unRAID-Jayred365"]="/root/.ssh/Gmer4Lfe-rsync-key" -SSH_KEYS["unRAID-Jayred365|unRAID-Gmer4Lfe"]="/root/.ssh/Jayred365-rsync-key" \ No newline at end of file +#----------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/common.sh b/common.sh index e1940f6..d1c4a3f 100644 --- a/common.sh +++ b/common.sh @@ -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" } \ No newline at end of file