Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Harden the installers against piped execution and v-prefixed versions

rcourtmanc98acb9e85cb
diff --git a/install.sh b/install.sh
index ab4baaa6f7..607840c4ca 100755
--- a/install.sh
+++ b/install.sh
@@ -5121,8 +5121,12 @@ reset_pulse() {
}
# When sourced (e.g. by tests) rather than executed, define the functions above
-# but do not run the installer.
-[[ "${BASH_SOURCE[0]}" == "$0" ]] || return 0
+# but do not run the installer. BASH_SOURCE is empty when the script is piped to
+# bash (curl ... | bash), which is an execution and not a source, so guard the
+# lookup with a default to avoid an "unbound variable" abort under `set -u`.
+if [[ -n "${BASH_SOURCE[0]:-}" && "${BASH_SOURCE[0]}" != "$0" ]]; then
+ return 0
+fi
# Parse command line arguments
while [[ $# -gt 0 ]]; do
diff --git a/scripts/install.sh b/scripts/install.sh
index 88ce8acd56..6534017334 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -2731,7 +2731,13 @@ verify_download_signature "$TMP_BIN" "$SSH_SIGNATURE_HEADER"
chmod +x "$TMP_BIN"
NEW_VERSION=$("$TMP_BIN" --version 2>/dev/null | head -1 || echo "unknown")
-if [[ -n "$SERVER_VERSION" && -n "$NEW_VERSION" && "$NEW_VERSION" != "unknown" && "$NEW_VERSION" != "$SERVER_VERSION" ]]; then
+# Compare versions with any leading "v" stripped so the agent binary's "v6.0.4"
+# and the server /api/version "6.0.4" are treated as equal. Only a genuine
+# version difference (e.g. 6.0.3 vs 6.0.4) should raise the mismatch warning.
+NEW_VERSION_NORMALIZED="${NEW_VERSION#v}"
+SERVER_VERSION_NORMALIZED="${SERVER_VERSION#v}"
+
+if [[ -n "$SERVER_VERSION" && -n "$NEW_VERSION" && "$NEW_VERSION" != "unknown" && "$NEW_VERSION_NORMALIZED" != "$SERVER_VERSION_NORMALIZED" ]]; then
log_warn "Downloaded agent version (${NEW_VERSION}) does not match Pulse server version (${SERVER_VERSION}). Check that Pulse is upgraded and that any reverse proxy is not serving a stale cached binary."
fi