update rsync to handle new master

This commit is contained in:
2026-03-24 22:47:01 +00:00
parent 1d806711c9
commit d1f51f6304
+23 -12
View File
@@ -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 <directory-to-sync> [--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 <directory-to-sync> [--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"