From c7351be94a6f8b81a6ba8b26e92c0643844258dd Mon Sep 17 00:00:00 2001 From: NoxMax <50133316+NoxMax@users.noreply.github.com> Date: Wed, 6 Aug 2025 00:48:48 -0600 Subject: [PATCH] fix(bash): Exit simple-restarter script if shutdown is requested (#22617) --- apps/startup-scripts/src/simple-restarter | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/startup-scripts/src/simple-restarter b/apps/startup-scripts/src/simple-restarter index 62aea7fbd..a158b38be 100755 --- a/apps/startup-scripts/src/simple-restarter +++ b/apps/startup-scripts/src/simple-restarter @@ -66,7 +66,7 @@ while true; do echo "$(basename "$BINARY") terminated after $DIFFERENCE seconds, restart count: $_restart_count" # Crash loop detection - if [ $DIFFERENCE -lt 10 ]; then + if [ "$DIFFERENCE" -lt 10 ]; then # Increment instant crash count if runtime is lower than 10 seconds ((_instant_crash_count++)) echo "Warning: Quick restart detected ($DIFFERENCE seconds) - instant crash count: $_instant_crash_count" @@ -76,11 +76,17 @@ while true; do fi # Prevent infinite crash loops - if [ $_instant_crash_count -gt 5 ]; then + if [ "$_instant_crash_count" -gt 5 ]; then echo "Error: $(basename "$BINARY") restarter exited. Infinite crash loop prevented (6 crashes in under 10 seconds each)" echo "Please check your system configuration and logs" exit 1 fi + + # Exit cleanly if shutdown was requested by command or SIGINT (exit code 0) + if [ "$_exit_code" -eq 0 ]; then + echo "$(basename "$BINARY") shutdown safely" + exit 0 + fi echo "$(basename "$BINARY") will restart in 3 seconds..." sleep 3