Docker_Essentials echo/log audit pass — all 8 scripts + Manual
Consistent two-tier output model across the entire folder: - Per-container banners, action lines, and list details → log (ENABLE_LOGGING=true only) - Section headers, summaries, counts, and status conclusions → echo (always visible) - Warnings and errors always visible regardless of log setting - Blank echo lines inside loops removed All scripts: added Lock Acquisition and Host Detection entries to OPERATIONAL SAFEGUARDS. Setup banners removed from docker_watchdog.sh, docker_weekly_restart.sh, downloaders_reset.sh (noise before any work happens). docker_watchdog.sh: removed success "Running as root" / "Docker found" setup lines; info() → log() for daemon-recovered and per-cycle header; removed per-cycle echo separator. docker_update.sh + docker_update_remaining.sh: docker pull stdout suppressed when ENABLE_LOGGING=false to prevent orphaned Status: lines appearing without container context; restructured pull block to use PIPESTATUS for exit code capture. downloaders_reset.sh: 11× info() → log() for all per-item API operation lines. docker_weekly_restart.sh: removed duplicate restart-order echo (build_restart_order already logs it internally). Manual-Docker_Essentials.md: documented the two-tier output model and watchdog silent-when-healthy exception in the flag reference section.
This commit is contained in:
@@ -31,6 +31,11 @@
|
||||
# All docker commands wrapped in a 30 second timeout. A hung Docker daemon
|
||||
# cannot cause this script to hang indefinitely.
|
||||
#
|
||||
# Host Detection
|
||||
# detect_hosts() identifies which server is running the script and aliases
|
||||
# HOST*_WEEKLY_RESTART_CONTAINERS and HOST*_WATCHDOG_DEPENDENCIES to the
|
||||
# correct host's values.
|
||||
#
|
||||
# Lock Acquisition
|
||||
# acquire_lock() prevents concurrent execution.
|
||||
#
|
||||
@@ -86,9 +91,6 @@ parse_args "$@"
|
||||
# ==============================================================================================
|
||||
# ━━━ Setup ━━━
|
||||
# ==============================================================================================
|
||||
echo ""
|
||||
echo "━━━ $ICON_GEAR Setup ━━━"
|
||||
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
error "Must be run as root"
|
||||
exit 1
|
||||
@@ -110,7 +112,7 @@ if [[ ${#WEEKLY_RESTART_CONTAINERS[@]} -eq 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo " $MY_ID ($LOCAL_SERVER_NAME) — ${#WEEKLY_RESTART_CONTAINERS[@]} containers configured"
|
||||
log "$MY_ID ($LOCAL_SERVER_NAME) — ${#WEEKLY_RESTART_CONTAINERS[@]} containers configured"
|
||||
|
||||
# ==============================================================================================
|
||||
# ━━━ Status ━━━
|
||||
@@ -232,7 +234,7 @@ check_dependency_delay() {
|
||||
[[ -z "$last" ]] && return
|
||||
local deps="${WATCHDOG_DEPENDENCIES[$container]:-}"
|
||||
if [[ -n "$deps" ]] && [[ "$deps" == *"$last"* ]]; then
|
||||
info "Waiting ${CONTAINER_DELAY}s — $container depends on $last..."
|
||||
log "Waiting ${CONTAINER_DELAY}s — $container depends on $last..."
|
||||
sleep "$CONTAINER_DELAY"
|
||||
fi
|
||||
}
|
||||
@@ -242,9 +244,8 @@ check_dependency_delay() {
|
||||
# ==============================================================================================
|
||||
echo ""
|
||||
echo "━━━ $ICON_CONTAINERS Weekly Restart — $(date '+%Y-%m-%d %H:%M:%S') ━━━"
|
||||
echo "$ICON_CONTAINERS Containers: ${WEEKLY_RESTART_CONTAINERS[*]}"
|
||||
echo "$ICON_RETRY Retries: $RETRY_COUNT"
|
||||
echo ""
|
||||
log "$ICON_CONTAINERS Containers: ${WEEKLY_RESTART_CONTAINERS[*]}"
|
||||
log "$ICON_RETRY Retries: $RETRY_COUNT"
|
||||
|
||||
START=$(date +%s)
|
||||
FAILED=()
|
||||
@@ -253,18 +254,15 @@ SKIPPED=()
|
||||
|
||||
# Build dependency-safe restart order
|
||||
build_restart_order
|
||||
echo "$ICON_GEAR Restart order: ${ORDERED_RESTART[*]}"
|
||||
echo ""
|
||||
|
||||
LAST_RESTARTED=""
|
||||
|
||||
for container in "${ORDERED_RESTART[@]}"; do
|
||||
[[ -z "$container" ]] && continue
|
||||
echo "━━━ $ICON_CONTAINERS $container ━━━"
|
||||
log "━━━ $ICON_CONTAINERS $container ━━━"
|
||||
|
||||
if ! timeout "$DOCKER_TIMEOUT" docker inspect "$container" &>/dev/null; then
|
||||
warn "$container does not exist — skipping"
|
||||
echo ""
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -272,7 +270,7 @@ for container in "${ORDERED_RESTART[@]}"; do
|
||||
|
||||
case "$STATUS" in
|
||||
true)
|
||||
echo "$ICON_RUNNING $container is running — restarting..."
|
||||
log "$ICON_RUNNING $container is running — restarting..."
|
||||
|
||||
# Wait if this container depends on the last one restarted
|
||||
check_dependency_delay "$container" "$LAST_RESTARTED"
|
||||
@@ -283,7 +281,7 @@ for container in "${ORDERED_RESTART[@]}"; do
|
||||
else
|
||||
if retry_docker docker restart "$container"; then
|
||||
if verify_running "$container"; then
|
||||
echo "$ICON_STARTED $container restarted and running ✅"
|
||||
log "$ICON_STARTED $container restarted and running ✅"
|
||||
RESTARTED+=("$container")
|
||||
LAST_RESTARTED="$container"
|
||||
else
|
||||
@@ -300,8 +298,7 @@ for container in "${ORDERED_RESTART[@]}"; do
|
||||
;;
|
||||
false)
|
||||
# Container was stopped — leave it stopped
|
||||
# Intentionally stopped containers are not restarted
|
||||
echo "$ICON_NOT_RUNNING $container is stopped — skipping (respecting stopped state)"
|
||||
log "$ICON_NOT_RUNNING $container is stopped — skipping (respecting stopped state)"
|
||||
SKIPPED+=("$container")
|
||||
;;
|
||||
*)
|
||||
@@ -310,7 +307,6 @@ for container in "${ORDERED_RESTART[@]}"; do
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ""
|
||||
done
|
||||
|
||||
END=$(date +%s)
|
||||
@@ -321,8 +317,11 @@ END=$(date +%s)
|
||||
echo "━━━━━ $ICON_SUMMARY WEEKLY RESTART SUMMARY ━━━━━"
|
||||
echo "$ICON_HOST Identity: $MY_ID ($LOCAL_SERVER_NAME)"
|
||||
echo "$ICON_TIME Duration: $(format_duration $((END - START)))"
|
||||
[[ ${#RESTARTED[@]} -gt 0 ]] && echo "$ICON_STARTED Restarted: ${RESTARTED[*]}"
|
||||
[[ ${#SKIPPED[@]} -gt 0 ]] && echo "$ICON_NOT_RUNNING Skipped: ${SKIPPED[*]} (were stopped)"
|
||||
if [[ ${#RESTARTED[@]} -gt 0 ]]; then
|
||||
echo "$ICON_STARTED Restarted: ${#RESTARTED[@]}"
|
||||
log " ${RESTARTED[*]}"
|
||||
fi
|
||||
[[ ${#SKIPPED[@]} -gt 0 ]] && log "$ICON_NOT_RUNNING Skipped: ${#SKIPPED[@]} (were stopped)"
|
||||
[[ ${#FAILED[@]} -gt 0 ]] && echo "$ICON_ERROR Failed: ${FAILED[*]}"
|
||||
|
||||
if [[ "$DRY_RUN" == true ]]; then
|
||||
|
||||
Reference in New Issue
Block a user