true bidirectional with split truth modle set up. all scripts are fully bidirectional
This commit is contained in:
+26
-6
@@ -23,12 +23,15 @@ source "$SCRIPT_DIR/../common.sh"
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Separate the positional directory argument from flag/key=value args.
|
||||
# Optional --profile=name overrides the basename profile inference.
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
DIRECTORY=""
|
||||
PROFILE_OVERRIDE=""
|
||||
RAW_ARGS=()
|
||||
|
||||
for ARG in "$@"; do
|
||||
case "$ARG" in
|
||||
--profile=*) PROFILE_OVERRIDE="${ARG#--profile=}" ;;
|
||||
--*|*=*) RAW_ARGS+=("$ARG") ;;
|
||||
*) [[ -z "$DIRECTORY" ]] && DIRECTORY="$ARG" || RAW_ARGS+=("$ARG") ;;
|
||||
esac
|
||||
@@ -36,7 +39,7 @@ done
|
||||
|
||||
parse_args "${RAW_ARGS[@]}"
|
||||
|
||||
[[ -z "$DIRECTORY" ]] && error "No directory specified. Usage: rsync.sh <dir> [--dry-run] [--log]" && exit 1
|
||||
[[ -z "$DIRECTORY" ]] && error "No directory specified. Usage: rsync.sh <dir> [--dry-run] [--log] [--profile=name]" && exit 1
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# ━━━ $ICON_GEAR Setup ━━━
|
||||
@@ -49,10 +52,16 @@ resolve_remote_ip
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
# Profile inference — basename of directory lowercased
|
||||
# Optional --profile=name overrides basename inference
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
echo ""
|
||||
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
||||
info "$ICON_GEAR Loading profile: $PROFILE_NAME"
|
||||
if [[ -n "$PROFILE_OVERRIDE" ]]; then
|
||||
PROFILE_NAME="$PROFILE_OVERRIDE"
|
||||
info "$ICON_GEAR Profile override: $PROFILE_NAME"
|
||||
else
|
||||
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
||||
info "$ICON_GEAR Loading profile: $PROFILE_NAME"
|
||||
fi
|
||||
|
||||
# Acquire per-profile lock and check global concurrent limit
|
||||
acquire_rsync_lock "$PROFILE_NAME"
|
||||
@@ -64,9 +73,12 @@ SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
||||
|
||||
# Array overrides
|
||||
read -r -a CRITICAL_CONTAINER_NAMES <<< "${PROFILE_CRITICAL_CONTAINER_NAMES[$PROFILE_NAME]:-}"
|
||||
read -r -a DELAYED_CONTAINERS <<< "${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]:-}"
|
||||
read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-}"
|
||||
read -r -a CRITICAL_CONTAINER_NAMES <<< "${PROFILE_CRITICAL_CONTAINER_NAMES[$PROFILE_NAME]:-}"
|
||||
read -r -a DELAYED_CONTAINERS <<< "${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]:-}"
|
||||
read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-}"
|
||||
|
||||
# Local and remote use the same container list — same naming scheme on both servers
|
||||
LOCAL_CRITICAL_CONTAINER_NAMES=("${CRITICAL_CONTAINER_NAMES[@]}")
|
||||
|
||||
# Disk check toggle
|
||||
SKIP_DISK_CHECK=${PROFILE_SKIP_DISK_CHECK[$PROFILE_NAME]:-false}
|
||||
@@ -95,6 +107,10 @@ fi
|
||||
echo ""
|
||||
echo "━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━"
|
||||
|
||||
# Stop local containers first — flush local databases before pushing
|
||||
stop_local_containers
|
||||
|
||||
# Stop remote containers — prevent writes while receiving
|
||||
stop_containers
|
||||
|
||||
# -----------------------------------------------------------------------------------------------
|
||||
@@ -140,8 +156,12 @@ done
|
||||
echo ""
|
||||
echo "━━━ $ICON_START $ICON_CONTAINERS Containers ━━━"
|
||||
|
||||
# Start remote containers first — they can be coming up while local restarts
|
||||
start_containers
|
||||
|
||||
# Start local containers
|
||||
start_local_containers
|
||||
|
||||
END=$(date +%s)
|
||||
DURATION=$((END - START))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user