added notify to all needed in unraid essentials

This commit is contained in:
2026-04-09 17:20:09 -04:00
parent d12e034ef1
commit 6cc26c8fb9
11 changed files with 249 additions and 210 deletions
+13 -8
View File
@@ -35,7 +35,7 @@ if [[ "$SHOW_STATUS" == true ]]; then
echo ""
echo "━━━━━ $ICON_SUMMARY STATUS ━━━━━"
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 "━━━━━━━━━━━━━━━━━━━━━━━"
exit 0
@@ -67,7 +67,7 @@ clear_file() {
# Skips gracefully if Docker directory or log files are not found.
clear_docker_logs() {
if [[ ! -d /var/lib/docker/containers ]]; then
warn "$ICON_DOCKER Docker directory not found — skipping"
warn "$ICON_CONTAINERS Docker directory not found — skipping"
return
fi
@@ -75,7 +75,7 @@ clear_docker_logs() {
files=$(find /var/lib/docker/containers/ -name "*-json.log" 2>/dev/null || true)
if [[ -z "$files" ]]; then
warn "$ICON_DOCKER No Docker logs found — skipping"
warn "$ICON_CONTAINERS No Docker logs found — skipping"
return
fi
@@ -95,20 +95,21 @@ clear_docker_logs() {
echo ""
echo "━━━ $ICON_HEALTH Clear Logs ━━━"
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 ""
[[ "$DRY_RUN" == true ]] && warn "DRY RUN — no changes will be made"
START=$(date +%s)
CLEAR_FAILED=false
for logfile in "${LOG_FILES[@]}"; do
clear_file "$logfile"
clear_file "$logfile" || CLEAR_FAILED=true
done
echo ""
echo "━━━ $ICON_DOCKER Docker ━━━"
echo "━━━ $ICON_CONTAINERS Docker ━━━"
clear_docker_logs
END=$(date +%s)
@@ -119,11 +120,15 @@ END=$(date +%s)
echo ""
echo "━━━━━ $ICON_SUMMARY LOG CLEANER SUMMARY ━━━━━"
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)))"
if [[ "$DRY_RUN" == true ]]; then
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
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
notify "Logs cleared successfully on $(hostname)" "Clear Logs" "normal"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+10 -3
View File
@@ -70,16 +70,17 @@ EOF
restart_rsyslog() {
if [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — would restart rsyslog service"
return
return 0
fi
info "Restarting rsyslog..."
if /etc/rc.d/rc.rsyslogd restart; then
success "rsyslog restarted"
return 0
else
error "Failed to restart rsyslog"
exit 1
return 1
fi
}
@@ -98,7 +99,9 @@ echo ""
START=$(date +%s)
create_filter
restart_rsyslog
RSYSLOG_OK=true
restart_rsyslog || RSYSLOG_OK=false
END=$(date +%s)
@@ -112,7 +115,11 @@ echo "$ICON_CONTAINERS Targets: veth / docker0"
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
if [[ "$DRY_RUN" == true ]]; then
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
echo "$ICON_DONE Status: $ICON_SUCCESS DONE"
notify "Syslog filter applied on $(hostname)" "Syslog Filter" "normal"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+3 -1
View File
@@ -108,7 +108,9 @@ echo "━━━━━ $ICON_SUMMARY MOVER STOP SUMMARY ━━━━━"
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
if check_mover_running; then
echo "$ICON_ERROR Status: $ICON_ERROR STILL RUNNING"
notify "Mover stop failed — mover still running on $(hostname)" "Mover Stop" "warning"
else
echo "$ICON_DONE Status: $ICON_SUCCESS STOPPED / NOT RUNNING"
notify "Mover stopped on $(hostname)" "Mover Stop" "normal"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
+23 -13
View File
@@ -58,33 +58,33 @@ apply_php_max_children() {
if [[ "$DRY_RUN" == true ]]; then
warn "DRY RUN — would set pm.max_children = $PHP_MAX_CHILDREN in $PHP_CONF"
warn "DRY RUN — would restart PHP-FPM service"
return
return 0
fi
# Verify config file exists before attempting changes
if [[ ! -f "$PHP_CONF" ]]; then
error "PHP config file not found: $PHP_CONF"
exit 1
return 1
fi
info "Applying pm.max_children = $PHP_MAX_CHILDREN..."
if sed -i "s/^pm\.max_children.*/$target/" "$PHP_CONF"; then
success "Config updated"
else
if ! sed -i "s/^pm\.max_children.*/$target/" "$PHP_CONF"; then
error "Failed to update PHP config: $PHP_CONF"
exit 1
return 1
fi
success "Config updated"
info "Restarting PHP-FPM..."
if /etc/rc.d/rc.php-fpm restart; then
success "PHP-FPM restarted"
else
if ! /etc/rc.d/rc.php-fpm restart; then
error "PHP-FPM restart failed"
exit 1
return 1
fi
success "PHP-FPM restarted"
# Verify the value was applied correctly
local current
current=$(grep -E "^pm\.max_children" "$PHP_CONF" || true)
@@ -95,6 +95,8 @@ apply_php_max_children() {
else
warn "Could not verify configuration value — check $PHP_CONF manually"
fi
return 0
}
# -----------------------------------------------------------------------------------------------
@@ -111,7 +113,8 @@ echo ""
START=$(date +%s)
apply_php_max_children
PHP_SUCCESS=false
apply_php_max_children && PHP_SUCCESS=true
END=$(date +%s)
@@ -125,7 +128,14 @@ echo "$ICON_PHP Max Children: $PHP_MAX_CHILDREN"
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
if [[ "$DRY_RUN" == true ]]; then
echo "$ICON_WARN Status: DRY RUN — no changes made"
else
elif [[ "$PHP_SUCCESS" == true ]]; then
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
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
[[ "$PHP_SUCCESS" == false ]] && exit 1
exit 0
+8 -1
View File
@@ -189,4 +189,11 @@ elif [[ "$LOCAL_KILLED" == true ]]; then
fi
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
+2 -1
View File
@@ -52,7 +52,6 @@ get_user_script_pids() {
# Kills all running User Script processes one by one.
# Reports each PID killed or skipped in dry run mode.
# Checks remaining processes after kill to confirm cleanup.
stop_user_scripts() {
local pids
pids=$(get_user_script_pids)
@@ -117,8 +116,10 @@ else
REMAINING=$(get_user_script_pids)
if [[ -z "$REMAINING" ]]; then
echo "$ICON_DONE Status: $ICON_SUCCESS ALL PROCESSES STOPPED"
notify "User Scripts stopped on $(hostname)" "User Script Stop" "warning"
else
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