added notify to all needed in unraid essentials
This commit is contained in:
+24
-19
@@ -6,34 +6,34 @@
|
|||||||
# Per-share rsync handled by rsync.sh — this script tracks pass/fail and total time only.
|
# Per-share rsync handled by rsync.sh — this script tracks pass/fail and total time only.
|
||||||
# Add or remove shares in Master.conf under DAILY_SYNC_SHARES.
|
# Add or remove shares in Master.conf under DAILY_SYNC_SHARES.
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
source "$SCRIPT_DIR/../Master.conf"
|
source "$SCRIPT_DIR/../Master.conf"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|
||||||
RSYNC_SCRIPT="$SCRIPT_DIR/../Rsync/rsync.sh"
|
RSYNC_SCRIPT="$SCRIPT_DIR/../Rsync/rsync.sh"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_GEAR Setup ━━━
|
# ━━━ $ICON_GEAR Setup ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_GEAR Setup ━━━"
|
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||||
|
|
||||||
detect_hosts
|
detect_hosts
|
||||||
resolve_remote_ip
|
resolve_remote_ip
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
|
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
|
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
|
||||||
|
|
||||||
# Single connectivity and rootfs check upfront — fail fast before attempting all shares
|
# Single connectivity and rootfs check upfront — fail fast before attempting all shares
|
||||||
# Individual share and disk checks run per-share inside rsync.sh
|
# Individual share and disk checks run per-share inside rsync.sh
|
||||||
check_connectivity
|
check_connectivity
|
||||||
check_remote_rootfs
|
check_remote_rootfs
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# Tracking
|
# Tracking
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
@@ -42,7 +42,7 @@ FAIL=()
|
|||||||
SHARE_TIMES=()
|
SHARE_TIMES=()
|
||||||
TOTAL_START=$(date +%s)
|
TOTAL_START=$(date +%s)
|
||||||
SHARE_COUNT=${#DAILY_SYNC_SHARES[@]}
|
SHARE_COUNT=${#DAILY_SYNC_SHARES[@]}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SYNC Transfer ━━━
|
# ━━━ $ICON_SYNC Transfer ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
@@ -50,16 +50,16 @@ echo ""
|
|||||||
echo "━━━ $ICON_SYNC Daily Sync Starting — $(date '+%Y-%m-%d %H:%M:%S') ━━━"
|
echo "━━━ $ICON_SYNC Daily Sync Starting — $(date '+%Y-%m-%d %H:%M:%S') ━━━"
|
||||||
echo "$ICON_SUMMARY Shares: $SHARE_COUNT"
|
echo "$ICON_SUMMARY Shares: $SHARE_COUNT"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
SHARE_INDEX=0
|
SHARE_INDEX=0
|
||||||
|
|
||||||
for SHARE in "${DAILY_SYNC_SHARES[@]}"; do
|
for SHARE in "${DAILY_SYNC_SHARES[@]}"; do
|
||||||
SHARE_INDEX=$((SHARE_INDEX + 1))
|
SHARE_INDEX=$((SHARE_INDEX + 1))
|
||||||
SHARE_NAME=$(basename "$SHARE")
|
SHARE_NAME=$(basename "$SHARE")
|
||||||
SHARE_START=$(date +%s)
|
SHARE_START=$(date +%s)
|
||||||
|
|
||||||
echo "━━━ $ICON_SYNC Share $SHARE_INDEX of $SHARE_COUNT: $SHARE_NAME ━━━"
|
echo "━━━ $ICON_SYNC Share $SHARE_INDEX of $SHARE_COUNT: $SHARE_NAME ━━━"
|
||||||
|
|
||||||
if bash "$RSYNC_SCRIPT" "$SHARE"; then
|
if bash "$RSYNC_SCRIPT" "$SHARE"; then
|
||||||
SHARE_END=$(date +%s)
|
SHARE_END=$(date +%s)
|
||||||
SHARE_TIMES+=("$SHARE_NAME:$((SHARE_END - SHARE_START))")
|
SHARE_TIMES+=("$SHARE_NAME:$((SHARE_END - SHARE_START))")
|
||||||
@@ -71,13 +71,13 @@ for SHARE in "${DAILY_SYNC_SHARES[@]}"; do
|
|||||||
FAIL+=("$SHARE_NAME")
|
FAIL+=("$SHARE_NAME")
|
||||||
error "$SHARE_NAME failed — continuing to next share"
|
error "$SHARE_NAME failed — continuing to next share"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
TOTAL_END=$(date +%s)
|
TOTAL_END=$(date +%s)
|
||||||
TOTAL_DURATION=$((TOTAL_END - TOTAL_START))
|
TOTAL_DURATION=$((TOTAL_END - TOTAL_START))
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SUMMARY Summary ━━━
|
# ━━━ $ICON_SUMMARY Summary ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
@@ -99,6 +99,11 @@ echo " $ICON_SUCCESS Passed: ${#PASS[@]}/$SHARE_COUNT"
|
|||||||
echo " $ICON_ERROR Failed: ${#FAIL[@]}/$SHARE_COUNT"
|
echo " $ICON_ERROR Failed: ${#FAIL[@]}/$SHARE_COUNT"
|
||||||
echo " $ICON_TIME Duration: $(format_duration $TOTAL_DURATION)"
|
echo " $ICON_TIME Duration: $(format_duration $TOTAL_DURATION)"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
[[ ${#FAIL[@]} -gt 0 ]] && exit 1
|
if [[ ${#FAIL[@]} -gt 0 ]]; then
|
||||||
exit 0
|
notify "Daily sync completed with failures — ${#FAIL[@]}/$SHARE_COUNT failed: ${FAIL[*]}" "Daily Sync" "warning"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
notify "Daily sync complete — ${#PASS[@]}/$SHARE_COUNT shares in $(format_duration $TOTAL_DURATION)" "Daily Sync" "normal"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# --------------------------------- Git Pull & Execute Script -----------------------------------
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# Pulls latest scripts from Gitea repo via SSH.
|
|
||||||
# Uses GITEA_SSH_KEY and SSH_PORT from Master.conf.
|
|
||||||
# Supports --dry-run, --log, --status flags via common.sh parse_args.
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
source "$SCRIPT_DIR/../Master.conf"
|
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
|
||||||
|
|
||||||
parse_args "$@"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# STATUS MODE
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
if [[ "$SHOW_STATUS" == true ]]; then
|
|
||||||
echo
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_SUMMARY GIT SYNC STATUS"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_GEAR Repo: $REPO_SSH"
|
|
||||||
echo " $ICON_GEAR Target: $TARGET_DIR"
|
|
||||||
echo " $ICON_GEAR SSH Key: $GITEA_SSH_KEY"
|
|
||||||
echo " $ICON_GEAR SSH Port: $SSH_PORT"
|
|
||||||
echo " $ICON_INFO Dry Run: $DRY_RUN"
|
|
||||||
echo " $ICON_INFO Logging: $ENABLE_LOGGING"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# VALIDATION
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
require_var REPO_SSH
|
|
||||||
require_var TARGET_DIR
|
|
||||||
require_var GITEA_SSH_KEY
|
|
||||||
require_var SSH_PORT
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# HEADER
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
echo
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_RUN GIT SYNC STARTING"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
info "$ICON_GEAR Repo: $REPO_SSH"
|
|
||||||
info "$ICON_GEAR Target: $TARGET_DIR"
|
|
||||||
info "$ICON_INFO Dry Run: $DRY_RUN"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
|
|
||||||
log "Repo: $REPO_SSH"
|
|
||||||
log "Target: $TARGET_DIR"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# DRY RUN
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
|
||||||
echo
|
|
||||||
warn "Dry-run enabled — no changes will be made"
|
|
||||||
info "Would sync: $REPO_SSH"
|
|
||||||
info "Would target: $TARGET_DIR"
|
|
||||||
echo
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_SUMMARY GIT SYNC SUMMARY"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_GEAR Repo: $REPO_SSH"
|
|
||||||
echo " $ICON_GEAR Target: $TARGET_DIR"
|
|
||||||
echo " $ICON_WARN Status: DRY RUN"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# MAIN EXECUTION
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
START_TIME=$(date +%s)
|
|
||||||
|
|
||||||
mkdir -p "$TARGET_DIR"
|
|
||||||
cd "$TARGET_DIR"
|
|
||||||
|
|
||||||
if [[ -d ".git" ]]; then
|
|
||||||
info "$ICON_SYNC Existing repository detected — updating"
|
|
||||||
log "git reset --hard"
|
|
||||||
git reset --hard
|
|
||||||
|
|
||||||
log "git clean -fd"
|
|
||||||
git clean -fd
|
|
||||||
|
|
||||||
info "$ICON_RUN Pulling latest changes..."
|
|
||||||
if GIT_SSH_COMMAND="ssh -i $GITEA_SSH_KEY -p $SSH_PORT" git pull; then
|
|
||||||
success "Git pull successful"
|
|
||||||
else
|
|
||||||
error "Git pull failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
info "$ICON_SYNC No repository found — cloning"
|
|
||||||
if GIT_SSH_COMMAND="ssh -i $GITEA_SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" .; then
|
|
||||||
success "Clone successful"
|
|
||||||
else
|
|
||||||
error "Clone failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# PERMISSIONS
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
info "$ICON_GEAR Setting executable permissions..."
|
|
||||||
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
|
|
||||||
success "Permissions applied"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
# SUMMARY
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
|
||||||
END_TIME=$(date +%s)
|
|
||||||
DURATION=$((END_TIME - START_TIME))
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_SUMMARY GIT SYNC SUMMARY"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
echo " $ICON_GEAR Repo: $REPO_SSH"
|
|
||||||
echo " $ICON_GEAR Target: $TARGET_DIR"
|
|
||||||
echo " $ICON_TIME Duration: $(format_duration $DURATION)"
|
|
||||||
echo " $ICON_SUCCESS Status: SUCCESS"
|
|
||||||
echo " $ICON_INFO Dry Run: $DRY_RUN"
|
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
||||||
success "Repository sync complete"
|
|
||||||
+31
-29
@@ -4,50 +4,50 @@
|
|||||||
# ----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
# ---------------- User Variables, Please adjust in Master.conf as needed ----------------------
|
||||||
# ----------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
source "$SCRIPT_DIR/../Master.conf"
|
source "$SCRIPT_DIR/../Master.conf"
|
||||||
source "$SCRIPT_DIR/../common.sh"
|
source "$SCRIPT_DIR/../common.sh"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# Separate the positional directory argument from flag/key=value args.
|
# Separate the positional directory argument from flag/key=value args.
|
||||||
# Flags and key=value pairs are passed to parse_args — directory is handled here.
|
# Flags and key=value pairs are passed to parse_args — directory is handled here.
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
DIRECTORY=""
|
DIRECTORY=""
|
||||||
RAW_ARGS=()
|
RAW_ARGS=()
|
||||||
|
|
||||||
for ARG in "$@"; do
|
for ARG in "$@"; do
|
||||||
case "$ARG" in
|
case "$ARG" in
|
||||||
--*|*=*) RAW_ARGS+=("$ARG") ;;
|
--*|*=*) RAW_ARGS+=("$ARG") ;;
|
||||||
*) [[ -z "$DIRECTORY" ]] && DIRECTORY="$ARG" || RAW_ARGS+=("$ARG") ;;
|
*) [[ -z "$DIRECTORY" ]] && DIRECTORY="$ARG" || RAW_ARGS+=("$ARG") ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
parse_args "${RAW_ARGS[@]}"
|
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]" && exit 1
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_GEAR Setup ━━━
|
# ━━━ $ICON_GEAR Setup ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_GEAR Setup ━━━"
|
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||||
|
|
||||||
detect_hosts
|
detect_hosts
|
||||||
resolve_remote_ip
|
resolve_remote_ip
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
|
# ━━━ $ICON_SHIELD Pre-flight Checks ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
|
echo "━━━ $ICON_SHIELD Pre-flight Checks ━━━"
|
||||||
|
|
||||||
check_connectivity
|
check_connectivity
|
||||||
check_remote_rootfs
|
check_remote_rootfs
|
||||||
check_remote_share "$DIRECTORY"
|
check_remote_share "$DIRECTORY"
|
||||||
check_remote_disks "$DIRECTORY"
|
check_remote_disks "$DIRECTORY"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# Profile is inferred from the directory basename (lowercased)
|
# Profile is inferred from the directory basename (lowercased)
|
||||||
# e.g. /mnt/user/appdata-Failover/Arrs_Stack → arrs_stack
|
# e.g. /mnt/user/appdata-Failover/Arrs_Stack → arrs_stack
|
||||||
@@ -55,28 +55,28 @@ check_remote_disks "$DIRECTORY"
|
|||||||
echo ""
|
echo ""
|
||||||
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
PROFILE_NAME=$(basename "$DIRECTORY" | tr '[:upper:]' '[:lower:]')
|
||||||
info "$ICON_GEAR Loading profile: $PROFILE_NAME"
|
info "$ICON_GEAR Loading profile: $PROFILE_NAME"
|
||||||
|
|
||||||
# Scalar overrides — use profile value if defined, fall back to global default
|
# Scalar overrides — use profile value if defined, fall back to global default
|
||||||
BW_LIMIT=${PROFILE_BW_LIMIT[$PROFILE_NAME]:-$BW_LIMIT}
|
BW_LIMIT=${PROFILE_BW_LIMIT[$PROFILE_NAME]:-$BW_LIMIT}
|
||||||
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
RETRY_COUNT=${PROFILE_RETRY_COUNT[$PROFILE_NAME]:-$RETRY_COUNT}
|
||||||
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
SLEEP=${PROFILE_SLEEP[$PROFILE_NAME]:-$SLEEP}
|
||||||
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
CONTAINER_DELAY=${PROFILE_CONTAINER_DELAY[$PROFILE_NAME]:-$CONTAINER_DELAY}
|
||||||
|
|
||||||
# Array overrides — profile strings must be converted to bash arrays before use
|
# Array overrides — profile strings must be converted to bash arrays before use
|
||||||
read -r -a CRITICAL_CONTAINER_NAMES <<< "${PROFILE_CRITICAL_CONTAINER_NAMES[$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 DELAYED_CONTAINERS <<< "${PROFILE_DELAYED_CONTAINERS[$PROFILE_NAME]:-}"
|
||||||
read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-}"
|
read -r -a EXCLUDE_DIRS <<< "${PROFILE_EXCLUDE_DIRS[$PROFILE_NAME]:-}"
|
||||||
|
|
||||||
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
|
[[ "$SHOW_STATUS" == true ]] && show_status && exit 0
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━
|
# ━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━"
|
echo "━━━ $ICON_STOP $ICON_CONTAINERS Containers ━━━"
|
||||||
|
|
||||||
stop_containers
|
stop_containers
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SYNC Transfer ━━━
|
# ━━━ $ICON_SYNC Transfer ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
@@ -86,22 +86,22 @@ echo "$ICON_RUN Source: $DIRECTORY"
|
|||||||
echo "$ICON_NET Remote: $REMOTE_SERVER:$DIRECTORY"
|
echo "$ICON_NET Remote: $REMOTE_SERVER:$DIRECTORY"
|
||||||
echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
get_rsync_opts
|
get_rsync_opts
|
||||||
|
|
||||||
# Append profile excludes to rsync options
|
# Append profile excludes to rsync options
|
||||||
for ex in "${EXCLUDE_DIRS[@]}"; do
|
for ex in "${EXCLUDE_DIRS[@]}"; do
|
||||||
[[ -n "$ex" ]] && RSYNC_OPTS+=(--exclude="$ex")
|
[[ -n "$ex" ]] && RSYNC_OPTS+=(--exclude="$ex")
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ "$DRY_RUN" == true ]] && RSYNC_OPTS+=("--dry-run") && warn "DRY RUN — no changes will be made"
|
[[ "$DRY_RUN" == true ]] && RSYNC_OPTS+=("--dry-run") && warn "DRY RUN — no changes will be made"
|
||||||
|
|
||||||
START=$(date +%s)
|
START=$(date +%s)
|
||||||
RSYNC_SUCCESS=false
|
RSYNC_SUCCESS=false
|
||||||
|
|
||||||
for i in $(seq 1 "$RETRY_COUNT"); do
|
for i in $(seq 1 "$RETRY_COUNT"); do
|
||||||
info "$ICON_RETRY Attempt $i of $RETRY_COUNT..."
|
info "$ICON_RETRY Attempt $i of $RETRY_COUNT..."
|
||||||
|
|
||||||
# dirname "$DIRECTORY" is intentional — rsync places the directory itself on the remote
|
# dirname "$DIRECTORY" is intentional — rsync places the directory itself on the remote
|
||||||
# e.g. source /mnt/user/Movies syncs to remote /mnt/user/Movies (not /mnt/user/Movies/Movies)
|
# e.g. source /mnt/user/Movies syncs to remote /mnt/user/Movies (not /mnt/user/Movies/Movies)
|
||||||
if rsync "${RSYNC_OPTS[@]}" \
|
if rsync "${RSYNC_OPTS[@]}" \
|
||||||
@@ -115,19 +115,19 @@ for i in $(seq 1 "$RETRY_COUNT"); do
|
|||||||
[[ "$i" -lt "$RETRY_COUNT" ]] && info "Retrying in ${SLEEP}s..." && sleep "$SLEEP"
|
[[ "$i" -lt "$RETRY_COUNT" ]] && info "Retrying in ${SLEEP}s..." && sleep "$SLEEP"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_START $ICON_CONTAINERS Containers ━━━
|
# ━━━ $ICON_START $ICON_CONTAINERS Containers ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_START $ICON_CONTAINERS Containers ━━━"
|
echo "━━━ $ICON_START $ICON_CONTAINERS Containers ━━━"
|
||||||
|
|
||||||
start_containers
|
start_containers
|
||||||
|
|
||||||
END=$(date +%s)
|
END=$(date +%s)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SUMMARY Summary ━━━
|
# ━━━ Summary ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━ $ICON_SUMMARY SUMMARY ━━━━━"
|
echo "━━━━━ $ICON_SUMMARY SUMMARY ━━━━━"
|
||||||
@@ -136,10 +136,12 @@ echo "$ICON_GEAR Profile: $PROFILE_NAME"
|
|||||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
if [[ "$RSYNC_SUCCESS" == true ]]; then
|
if [[ "$RSYNC_SUCCESS" == true ]]; then
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
||||||
|
notify "Rsync complete — $DIRECTORY ($PROFILE_NAME) in $(format_duration $((END - START)))" "Rsync" "normal"
|
||||||
else
|
else
|
||||||
echo "$ICON_ERROR Status: $ICON_ERROR FAILED after $RETRY_COUNT attempts"
|
echo "$ICON_ERROR Status: $ICON_ERROR FAILED after $RETRY_COUNT attempts"
|
||||||
|
notify "Rsync failed — $DIRECTORY ($PROFILE_NAME) after $RETRY_COUNT attempts" "Rsync" "warning"
|
||||||
fi
|
fi
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
[[ "$RSYNC_SUCCESS" == false ]] && exit 1
|
[[ "$RSYNC_SUCCESS" == false ]] && exit 1
|
||||||
exit 0
|
exit 0
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# --------------------------------- Git Pull & Execute Script -----------------------------------
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# Pulls latest scripts from Gitea repo via SSH and sets executable permissions.
|
||||||
|
# Lives at the repo root — sources Master.conf and common.sh from the same directory.
|
||||||
|
# Uses GITEA_SSH_KEY, SSH_PORT and REPO_SSH from Master.conf.
|
||||||
|
# Supports --dry-run, --log, --status flags via common.sh parse_args.
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Root level script — sources from same directory, not parent
|
||||||
|
source "$SCRIPT_DIR/Master.conf"
|
||||||
|
source "$SCRIPT_DIR/common.sh"
|
||||||
|
|
||||||
|
parse_args "$@"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# ━━━ $ICON_GEAR Setup ━━━
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||||
|
|
||||||
|
# ROOT CHECK
|
||||||
|
if [[ "$EUID" -ne 0 ]]; then
|
||||||
|
error "Must be run as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
success "Running as root"
|
||||||
|
|
||||||
|
# VALIDATION
|
||||||
|
require_var REPO_SSH
|
||||||
|
require_var TARGET_DIR
|
||||||
|
require_var GITEA_SSH_KEY
|
||||||
|
require_var SSH_PORT
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# ━━━ $ICON_SUMMARY Status ━━━
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
if [[ "$SHOW_STATUS" == true ]]; then
|
||||||
|
echo ""
|
||||||
|
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
|
||||||
|
echo "$ICON_NET Repo: $REPO_SSH"
|
||||||
|
echo "$ICON_GEAR Target: $TARGET_DIR"
|
||||||
|
echo "$ICON_GEAR SSH Key: $GITEA_SSH_KEY"
|
||||||
|
echo "$ICON_GEAR SSH Port: $SSH_PORT"
|
||||||
|
echo "$ICON_NOTIFY Notifications: unRAID=${NOTIFY_UNRAID:-false} Discord=$([[ -n "${DISCORD_WEBHOOK:-}" ]] && echo enabled || echo disabled)"
|
||||||
|
echo "$ICON_GEAR Dry Run: $DRY_RUN"
|
||||||
|
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no changes will be made"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# ━━━ $ICON_SYNC Git Sync ━━━
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "━━━ $ICON_SYNC Git Sync ━━━"
|
||||||
|
echo "$ICON_NET Repo: $REPO_SSH"
|
||||||
|
echo "$ICON_GEAR Target: $TARGET_DIR"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
START=$(date +%s)
|
||||||
|
SYNC_SUCCESS=false
|
||||||
|
|
||||||
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
|
warn "DRY RUN — would sync $REPO_SSH → $TARGET_DIR"
|
||||||
|
SYNC_SUCCESS=true
|
||||||
|
else
|
||||||
|
mkdir -p "$TARGET_DIR"
|
||||||
|
cd "$TARGET_DIR" || { error "Cannot cd into $TARGET_DIR"; exit 1; }
|
||||||
|
|
||||||
|
if [[ -d ".git" ]]; then
|
||||||
|
info "$ICON_SYNC Existing repository detected — updating"
|
||||||
|
log "git reset --hard"
|
||||||
|
git reset --hard
|
||||||
|
|
||||||
|
log "git clean -fd"
|
||||||
|
git clean -fd
|
||||||
|
|
||||||
|
info "Pulling latest changes..."
|
||||||
|
if GIT_SSH_COMMAND="ssh -i $GITEA_SSH_KEY -p $SSH_PORT" git pull; then
|
||||||
|
success "Git pull successful"
|
||||||
|
SYNC_SUCCESS=true
|
||||||
|
else
|
||||||
|
error "Git pull failed"
|
||||||
|
notify "Git pull failed on $(hostname) — check Gitea connectivity" "Git Sync" "alert"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
info "$ICON_SYNC No repository found — cloning"
|
||||||
|
if GIT_SSH_COMMAND="ssh -i $GITEA_SSH_KEY -p $SSH_PORT" git clone "$REPO_SSH" .; then
|
||||||
|
success "Clone successful"
|
||||||
|
SYNC_SUCCESS=true
|
||||||
|
else
|
||||||
|
error "Clone failed"
|
||||||
|
notify "Git clone failed on $(hostname) — check Gitea connectivity" "Git Sync" "alert"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# ━━━ $ICON_GEAR Permissions ━━━
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "━━━ $ICON_GEAR Permissions ━━━"
|
||||||
|
info "Setting executable permissions on all .sh files..."
|
||||||
|
find "$TARGET_DIR" -type f -name "*.sh" -exec chmod +x {} \;
|
||||||
|
success "Permissions applied"
|
||||||
|
fi
|
||||||
|
|
||||||
|
END=$(date +%s)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
# ━━━ $ICON_SUMMARY Summary ━━━
|
||||||
|
# -----------------------------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "━━━━━ $ICON_SUMMARY GIT SYNC SUMMARY ━━━━━"
|
||||||
|
echo "$ICON_NET Repo: $REPO_SSH"
|
||||||
|
echo "$ICON_GEAR Target: $TARGET_DIR"
|
||||||
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
|
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
||||||
|
elif [[ "$SYNC_SUCCESS" == true ]]; then
|
||||||
|
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
||||||
|
notify "Repository synced successfully on $(hostname)" "Git Sync" "normal"
|
||||||
|
else
|
||||||
|
echo "$ICON_ERROR Status: $ICON_ERROR FAILED"
|
||||||
|
fi
|
||||||
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
@@ -35,7 +35,7 @@ if [[ "$SHOW_STATUS" == true ]]; then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
|
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
|
||||||
echo "$ICON_HEALTH System Logs: ${LOG_FILES[*]}"
|
echo "$ICON_HEALTH System Logs: ${LOG_FILES[*]}"
|
||||||
echo "$ICON_DOCKER Docker Logs: /var/lib/docker/containers"
|
echo "$ICON_CONTAINERS Docker Logs: /var/lib/docker/containers"
|
||||||
echo "$ICON_GEAR Dry Run: $DRY_RUN"
|
echo "$ICON_GEAR Dry Run: $DRY_RUN"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -67,7 +67,7 @@ clear_file() {
|
|||||||
# Skips gracefully if Docker directory or log files are not found.
|
# Skips gracefully if Docker directory or log files are not found.
|
||||||
clear_docker_logs() {
|
clear_docker_logs() {
|
||||||
if [[ ! -d /var/lib/docker/containers ]]; then
|
if [[ ! -d /var/lib/docker/containers ]]; then
|
||||||
warn "$ICON_DOCKER Docker directory not found — skipping"
|
warn "$ICON_CONTAINERS Docker directory not found — skipping"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ clear_docker_logs() {
|
|||||||
files=$(find /var/lib/docker/containers/ -name "*-json.log" 2>/dev/null || true)
|
files=$(find /var/lib/docker/containers/ -name "*-json.log" 2>/dev/null || true)
|
||||||
|
|
||||||
if [[ -z "$files" ]]; then
|
if [[ -z "$files" ]]; then
|
||||||
warn "$ICON_DOCKER No Docker logs found — skipping"
|
warn "$ICON_CONTAINERS No Docker logs found — skipping"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -95,20 +95,21 @@ clear_docker_logs() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_HEALTH Clear Logs ━━━"
|
echo "━━━ $ICON_HEALTH Clear Logs ━━━"
|
||||||
echo "$ICON_HEALTH System Logs: ${LOG_FILES[*]}"
|
echo "$ICON_HEALTH System Logs: ${LOG_FILES[*]}"
|
||||||
echo "$ICON_DOCKER Docker Logs: enabled"
|
echo "$ICON_CONTAINERS Docker Logs: enabled"
|
||||||
echo "$ICON_GEAR Dry Run: $DRY_RUN"
|
echo "$ICON_GEAR Dry Run: $DRY_RUN"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no changes will be made"
|
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no changes will be made"
|
||||||
|
|
||||||
START=$(date +%s)
|
START=$(date +%s)
|
||||||
|
CLEAR_FAILED=false
|
||||||
|
|
||||||
for logfile in "${LOG_FILES[@]}"; do
|
for logfile in "${LOG_FILES[@]}"; do
|
||||||
clear_file "$logfile"
|
clear_file "$logfile" || CLEAR_FAILED=true
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━ $ICON_DOCKER Docker ━━━"
|
echo "━━━ $ICON_CONTAINERS Docker ━━━"
|
||||||
clear_docker_logs
|
clear_docker_logs
|
||||||
|
|
||||||
END=$(date +%s)
|
END=$(date +%s)
|
||||||
@@ -119,11 +120,15 @@ END=$(date +%s)
|
|||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━ $ICON_SUMMARY LOG CLEANER SUMMARY ━━━━━"
|
echo "━━━━━ $ICON_SUMMARY LOG CLEANER SUMMARY ━━━━━"
|
||||||
echo "$ICON_HEALTH System Logs: ${LOG_FILES[*]}"
|
echo "$ICON_HEALTH System Logs: ${LOG_FILES[*]}"
|
||||||
echo "$ICON_DOCKER Docker Logs: $([[ "$DRY_RUN" == true ]] && echo "skipped (dry run)" || echo "cleared")"
|
echo "$ICON_CONTAINERS Docker Logs: $([[ "$DRY_RUN" == true ]] && echo "skipped (dry run)" || echo "cleared")"
|
||||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
||||||
|
elif [[ "$CLEAR_FAILED" == true ]]; then
|
||||||
|
echo "$ICON_ERROR Status: $ICON_ERROR SOME LOGS FAILED TO CLEAR"
|
||||||
|
notify "Log clear completed with errors on $(hostname)" "Clear Logs" "warning"
|
||||||
else
|
else
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
||||||
|
notify "Logs cleared successfully on $(hostname)" "Clear Logs" "normal"
|
||||||
fi
|
fi
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
@@ -70,16 +70,17 @@ EOF
|
|||||||
restart_rsyslog() {
|
restart_rsyslog() {
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
warn "DRY RUN — would restart rsyslog service"
|
warn "DRY RUN — would restart rsyslog service"
|
||||||
return
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Restarting rsyslog..."
|
info "Restarting rsyslog..."
|
||||||
|
|
||||||
if /etc/rc.d/rc.rsyslogd restart; then
|
if /etc/rc.d/rc.rsyslogd restart; then
|
||||||
success "rsyslog restarted"
|
success "rsyslog restarted"
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
error "Failed to restart rsyslog"
|
error "Failed to restart rsyslog"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +99,9 @@ echo ""
|
|||||||
START=$(date +%s)
|
START=$(date +%s)
|
||||||
|
|
||||||
create_filter
|
create_filter
|
||||||
restart_rsyslog
|
|
||||||
|
RSYSLOG_OK=true
|
||||||
|
restart_rsyslog || RSYSLOG_OK=false
|
||||||
|
|
||||||
END=$(date +%s)
|
END=$(date +%s)
|
||||||
|
|
||||||
@@ -112,7 +115,11 @@ echo "$ICON_CONTAINERS Targets: veth / docker0"
|
|||||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
||||||
|
elif [[ "$RSYSLOG_OK" == false ]]; then
|
||||||
|
echo "$ICON_ERROR Status: $ICON_ERROR RSYSLOG RESTART FAILED"
|
||||||
|
notify "rsyslog restart failed on $(hostname) — syslog filter may not be active" "Syslog Filter" "warning"
|
||||||
else
|
else
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
||||||
|
notify "Syslog filter applied on $(hostname)" "Syslog Filter" "normal"
|
||||||
fi
|
fi
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
@@ -108,7 +108,9 @@ echo "━━━━━ $ICON_SUMMARY MOVER STOP SUMMARY ━━━━━"
|
|||||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
if check_mover_running; then
|
if check_mover_running; then
|
||||||
echo "$ICON_ERROR Status: $ICON_ERROR STILL RUNNING"
|
echo "$ICON_ERROR Status: $ICON_ERROR STILL RUNNING"
|
||||||
|
notify "Mover stop failed — mover still running on $(hostname)" "Mover Stop" "warning"
|
||||||
else
|
else
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS STOPPED / NOT RUNNING"
|
echo "$ICON_DONE Status: $ICON_SUCCESS STOPPED / NOT RUNNING"
|
||||||
|
notify "Mover stopped on $(hostname)" "Mover Stop" "normal"
|
||||||
fi
|
fi
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
@@ -58,33 +58,33 @@ apply_php_max_children() {
|
|||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
warn "DRY RUN — would set pm.max_children = $PHP_MAX_CHILDREN in $PHP_CONF"
|
warn "DRY RUN — would set pm.max_children = $PHP_MAX_CHILDREN in $PHP_CONF"
|
||||||
warn "DRY RUN — would restart PHP-FPM service"
|
warn "DRY RUN — would restart PHP-FPM service"
|
||||||
return
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify config file exists before attempting changes
|
# Verify config file exists before attempting changes
|
||||||
if [[ ! -f "$PHP_CONF" ]]; then
|
if [[ ! -f "$PHP_CONF" ]]; then
|
||||||
error "PHP config file not found: $PHP_CONF"
|
error "PHP config file not found: $PHP_CONF"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Applying pm.max_children = $PHP_MAX_CHILDREN..."
|
info "Applying pm.max_children = $PHP_MAX_CHILDREN..."
|
||||||
|
|
||||||
if sed -i "s/^pm\.max_children.*/$target/" "$PHP_CONF"; then
|
if ! sed -i "s/^pm\.max_children.*/$target/" "$PHP_CONF"; then
|
||||||
success "Config updated"
|
|
||||||
else
|
|
||||||
error "Failed to update PHP config: $PHP_CONF"
|
error "Failed to update PHP config: $PHP_CONF"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
success "Config updated"
|
||||||
|
|
||||||
info "Restarting PHP-FPM..."
|
info "Restarting PHP-FPM..."
|
||||||
|
|
||||||
if /etc/rc.d/rc.php-fpm restart; then
|
if ! /etc/rc.d/rc.php-fpm restart; then
|
||||||
success "PHP-FPM restarted"
|
|
||||||
else
|
|
||||||
error "PHP-FPM restart failed"
|
error "PHP-FPM restart failed"
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
success "PHP-FPM restarted"
|
||||||
|
|
||||||
# Verify the value was applied correctly
|
# Verify the value was applied correctly
|
||||||
local current
|
local current
|
||||||
current=$(grep -E "^pm\.max_children" "$PHP_CONF" || true)
|
current=$(grep -E "^pm\.max_children" "$PHP_CONF" || true)
|
||||||
@@ -95,6 +95,8 @@ apply_php_max_children() {
|
|||||||
else
|
else
|
||||||
warn "Could not verify configuration value — check $PHP_CONF manually"
|
warn "Could not verify configuration value — check $PHP_CONF manually"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
@@ -111,7 +113,8 @@ echo ""
|
|||||||
|
|
||||||
START=$(date +%s)
|
START=$(date +%s)
|
||||||
|
|
||||||
apply_php_max_children
|
PHP_SUCCESS=false
|
||||||
|
apply_php_max_children && PHP_SUCCESS=true
|
||||||
|
|
||||||
END=$(date +%s)
|
END=$(date +%s)
|
||||||
|
|
||||||
@@ -125,7 +128,14 @@ echo "$ICON_PHP Max Children: $PHP_MAX_CHILDREN"
|
|||||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||||
if [[ "$DRY_RUN" == true ]]; then
|
if [[ "$DRY_RUN" == true ]]; then
|
||||||
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
echo "$ICON_WARN Status: DRY RUN — no changes made"
|
||||||
else
|
elif [[ "$PHP_SUCCESS" == true ]]; then
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
|
||||||
|
notify "PHP-FPM max_children set to $PHP_MAX_CHILDREN on $(hostname)" "PHP-FPM" "normal"
|
||||||
|
else
|
||||||
|
echo "$ICON_ERROR Status: $ICON_ERROR FAILED"
|
||||||
|
notify "PHP-FPM config update failed on $(hostname)" "PHP-FPM" "warning"
|
||||||
fi
|
fi
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
|
[[ "$PHP_SUCCESS" == false ]] && exit 1
|
||||||
|
exit 0
|
||||||
@@ -189,4 +189,11 @@ elif [[ "$LOCAL_KILLED" == true ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$ICON_TIME Dry Run: $DRY_RUN"
|
echo "$ICON_TIME Dry Run: $DRY_RUN"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
|
# Notify based on what happened
|
||||||
|
if [[ "$LOCAL_KILLED" == true ]] || [[ "$REMOTE_KILLED" == true ]]; then
|
||||||
|
local_status=$([[ "$LOCAL_KILLED" == true ]] && echo "killed" || echo "clean")
|
||||||
|
remote_status=$([[ "$REMOTE_KILLED" == true ]] && echo "killed" || echo "clean")
|
||||||
|
notify "Rsync stopped — local: $local_status remote: $remote_status — ${#CONTAINERS_RESTARTED[@]} containers recovered" "Rsync Stop" "warning"
|
||||||
|
fi
|
||||||
@@ -52,7 +52,6 @@ get_user_script_pids() {
|
|||||||
|
|
||||||
# Kills all running User Script processes one by one.
|
# Kills all running User Script processes one by one.
|
||||||
# Reports each PID killed or skipped in dry run mode.
|
# Reports each PID killed or skipped in dry run mode.
|
||||||
# Checks remaining processes after kill to confirm cleanup.
|
|
||||||
stop_user_scripts() {
|
stop_user_scripts() {
|
||||||
local pids
|
local pids
|
||||||
pids=$(get_user_script_pids)
|
pids=$(get_user_script_pids)
|
||||||
@@ -117,8 +116,10 @@ else
|
|||||||
REMAINING=$(get_user_script_pids)
|
REMAINING=$(get_user_script_pids)
|
||||||
if [[ -z "$REMAINING" ]]; then
|
if [[ -z "$REMAINING" ]]; then
|
||||||
echo "$ICON_DONE Status: $ICON_SUCCESS ALL PROCESSES STOPPED"
|
echo "$ICON_DONE Status: $ICON_SUCCESS ALL PROCESSES STOPPED"
|
||||||
|
notify "User Scripts stopped on $(hostname)" "User Script Stop" "warning"
|
||||||
else
|
else
|
||||||
echo "$ICON_WARN Status: $ICON_WARN SOME PROCESSES MAY STILL BE RUNNING"
|
echo "$ICON_WARN Status: $ICON_WARN SOME PROCESSES MAY STILL BE RUNNING"
|
||||||
|
notify "User Script stop completed but some processes may still be running on $(hostname)" "User Script Stop" "warning"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
# no concurrency needed, bandwidth limiting keeps things sane if appdata jobs overlap.
|
# no concurrency needed, bandwidth limiting keeps things sane if appdata jobs overlap.
|
||||||
#
|
#
|
||||||
# This is where 80% of your rsync shares should live. Only create individual scheduled
|
# This is where 80% of your rsync shares should live. Only create individual scheduled
|
||||||
# entries for shares that need their own timing — like appdata profiles above.
|
# entries for shares that need their own timing — like appdata profiles below.
|
||||||
#
|
#
|
||||||
# ━━━ Orchestrators ━━━
|
# ━━━ Orchestrators ━━━
|
||||||
#/mnt/user/appdata/unraid_scripts/Orchestrators/daily_sync.sh
|
#/mnt/user/appdata/unraid_scripts/Orchestrators/daily_sync.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user