test commit for Master.conf and common.sh updates
This commit is contained in:
+6
-7
@@ -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"
|
||||
#-----------------------------------------------------------------------------------------------
|
||||
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user