added notify to all needed in unraid essentials
This commit is contained in:
@@ -100,5 +100,10 @@ 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
|
||||||
|
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
|
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"
|
|
||||||
+3
-1
@@ -127,7 +127,7 @@ start_containers
|
|||||||
END=$(date +%s)
|
END=$(date +%s)
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
# ━━━ $ICON_SUMMARY Summary ━━━
|
# ━━━ Summary ━━━
|
||||||
# -----------------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━ $ICON_SUMMARY SUMMARY ━━━━━"
|
echo "━━━━━ $ICON_SUMMARY SUMMARY ━━━━━"
|
||||||
@@ -136,8 +136,10 @@ 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 "━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -190,3 +190,10 @@ 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