From d1f51f6304d7ddacac8d9052874befb699ecd3fc Mon Sep 17 00:00:00 2001 From: FailedProxy Date: Tue, 24 Mar 2026 22:47:01 +0000 Subject: [PATCH] update rsync to handle new master --- Rsync/rsync.sh | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Rsync/rsync.sh b/Rsync/rsync.sh index 03e4ea2..3fc3f4a 100644 --- a/Rsync/rsync.sh +++ b/Rsync/rsync.sh @@ -1,12 +1,18 @@ #!/bin/bash set -e +#----------------------------------------------------------------------------------------------- +# Main Rsync Script for unRAID +#----------------------------------------------------------------------------------------------- #--------------------------------------------- -# Detect script directory and load Master.conf +# Detect script directory #--------------------------------------------- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -MASTER_CONF="$SCRIPT_DIR/../Master.conf" +#--------------------------------------------- +# Load Master.conf (hosts, keys, profiles, helpers) +#--------------------------------------------- +MASTER_CONF="$SCRIPT_DIR/../Master.conf" if [ -f "$MASTER_CONF" ]; then source "$MASTER_CONF" echo "Loaded Master.conf from $MASTER_CONF" @@ -16,21 +22,26 @@ else fi #--------------------------------------------- -# Parse arguments (using Master.conf helper) +# Input Arguments: Directory (positional) +#--------------------------------------------- +DIRECTORY="$1" +if [[ -z "$DIRECTORY" ]]; then + echo "Usage: $0 [--dry-run|-n] [VAR=value ...]" + exit 1 +fi +shift 1 # Remove directory from $@ so parse_args sees only options/VARs + +#--------------------------------------------- +# Parse optional arguments (dry-run / VAR=VALUE) #--------------------------------------------- parse_args "$@" -DIRECTORY="$1" -if [[ -z "$DIRECTORY" ]]; then - echo "Usage: $0 [--dry-run] [VAR=value ...]" - exit 1 -fi +echo "Detected profile: $(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')" #--------------------------------------------- -# Determine profile & apply defaults +# Apply profile defaults or fallback to Master.conf #--------------------------------------------- PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]') -echo "Detected profile: $PROFILE_NAME" MAX_RSYNC_PROCS=${PROFILE_MAX_PROCS[$PROFILE_NAME]:-$MAX_RSYNC_PROCS} BW_LIMIT=${PROFILE_BW_LIMIT[$PROFILE_NAME]:-$BW_LIMIT} @@ -56,7 +67,7 @@ done trap 'echo "Script interrupted. Exiting."; exit 130' INT TERM #--------------------------------------------- -# Helper functions +# Helper Functions #--------------------------------------------- wait_for_rsync() { for attempt in $(seq 1 "$RETRY_COUNT"); do @@ -84,7 +95,7 @@ stop_containers() { for container in "${CRITICAL_CONTAINER_NAMES[@]}"; do STATUS=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ "docker inspect -f '{{.State.Running}}' $container 2>/dev/null" || echo "false") - if [[ "$STATUS" == "true" ]]; then + if [ "$STATUS" == "true" ]; then echo "Stopping $container" RUNNING_CONTAINERS+=("$container") ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" "docker stop $container"