Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Make update checks tolerant and add empty-dir test

Juan Denisa90c56428f2d
diff --git a/scripts/test/test_update.sh b/scripts/test/test_update.sh
index 58051cee..60e1716d 100644
--- a/scripts/test/test_update.sh
+++ b/scripts/test/test_update.sh
@@ -393,6 +393,18 @@ else
bad "discover_app_upstreams returned [$res], expected the two unique upstreams"
fi
+# T16b — empty app-locations directory must not abort under set -euo pipefail.
+mkdir -p "$t/empty"
+if res="$( set -Eeuo pipefail; APP_LOCATIONS_DIR="$t/empty"; discover_app_upstreams )"; then
+ if [ -z "$res" ]; then
+ ok "discover_app_upstreams tolerates an empty app-locations directory"
+ else
+ bad "discover_app_upstreams returned [$res] for an empty directory, expected empty"
+ fi
+else
+ bad "discover_app_upstreams aborted on an empty app-locations directory"
+fi
+
# --------------------------------------------------------------------------
# T17 — report_app_uptime_regressions flags an app that was reachable before the
# update and is not after (and ignores one that was already down), returning
diff --git a/scripts/update.sh b/scripts/update.sh
index d4e59af8..95e6bb7e 100644
--- a/scripts/update.sh
+++ b/scripts/update.sh
@@ -275,7 +275,7 @@ remote_release_tag() {
return 0
fi
curl -sf "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" 2>/dev/null \
- | grep '"tag_name"' | head -1 | cut -d'"' -f4
+ | grep '"tag_name"' | head -1 | cut -d'"' -f4 || true
}
# Return 0 when the install is already at the target version/ref (the caller
@@ -1460,7 +1460,7 @@ NEXT_DIR="$(next_real_dir)"
if [ "$USE_RELEASE" = "1" ]; then
if [ -z "$RELEASE_VERSION" ]; then
RELEASE_VERSION="$(curl -sf "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" \
- | grep '"tag_name"' | head -1 | cut -d'"' -f4)"
+ | grep '"tag_name"' | head -1 | cut -d'"' -f4 || true)"
[ -n "$RELEASE_VERSION" ] || halt "Could not determine the latest release"
fi
step "Updating to release $RELEASE_VERSION"