From 7ec8606df21421da949633cd1f293804c598d067 Mon Sep 17 00:00:00 2001 From: Exaviz Date: Tue, 30 Jun 2026 19:08:40 -0400 Subject: [PATCH] fix: guard nginx reload when sudo is unavailable nginx.sh always called `sudo nginx -s reload`, which fails on hosts where the script already runs as root and `sudo` is not installed (common in minimal/root container environments). Run `nginx -s reload` directly when already root, fall back to `sudo` when available, and otherwise print a clear hint instead of failing. Fixes the case reported upstream in huly-selfhost#277. Signed-off-by: Exaviz --- nginx.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nginx.sh b/nginx.sh index 9dcec87..d26a36a 100755 --- a/nginx.sh +++ b/nginx.sh @@ -68,9 +68,15 @@ fi read -p "Do you want to run 'nginx -s reload' now to load your updated Huly config? (Y/n): " RUN_NGINX case "${RUN_NGINX:-Y}" in - [Yy]* ) + [Yy]* ) echo -e "\033[1;32mRunning 'nginx -s reload' now...\033[0m" - sudo nginx -s reload + if [ "$(id -u)" -eq 0 ]; then + nginx -s reload + elif command -v sudo >/dev/null 2>&1; then + sudo nginx -s reload + else + echo "Not running as root and 'sudo' is not available; run 'nginx -s reload' yourself as root." + fi ;; [Nn]* ) echo "You can run 'nginx -s reload' later to load your updated Huly config."