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.

Fix update_allowed_nodes to remove comment headers

rcourtman3e38159882ad
diff --git a/scripts/install-sensor-proxy.sh b/scripts/install-sensor-proxy.sh
index 636c2c7050..9065eb0c79 100755
--- a/scripts/install-sensor-proxy.sh
+++ b/scripts/install-sensor-proxy.sh
@@ -73,15 +73,48 @@ update_allowed_nodes() {
tmp_config=$(mktemp)
# Remove any existing allowed_nodes section (including the YAML key and all list items)
- # This handles multi-line allowed_nodes blocks by removing from "allowed_nodes:" through the next non-indented line
+ # This handles multi-line allowed_nodes blocks and associated comment headers
if [[ -f "$config_file" ]]; then
awk '
- /^allowed_nodes:/ { in_section=1; next }
- in_section && /^[^ \t#]/ { in_section=0 }
- in_section && /^[ \t]*#/ { next }
- in_section && /^[ \t]*-/ { next }
- in_section && /^[ \t]*$/ { next }
- !in_section { print }
+ # When we hit allowed_nodes, mark section start and clear pending comments
+ /^allowed_nodes:/ {
+ in_section=1
+ delete pending_lines
+ pending_count=0
+ next
+ }
+
+ # Inside section: skip all content until we hit a non-indented, non-comment line
+ in_section && /^[^ \t#]/ {
+ in_section=0
+ # Fall through to print this line
+ }
+ in_section {
+ next
+ }
+
+ # Outside section: buffer comment lines (they might belong to allowed_nodes)
+ !in_section && /^[ \t]*#/ {
+ pending_lines[pending_count++] = $0
+ next
+ }
+
+ # Outside section: non-comment line - flush pending comments and print
+ !in_section {
+ for (i = 0; i < pending_count; i++) {
+ print pending_lines[i]
+ }
+ delete pending_lines
+ pending_count = 0
+ print
+ }
+
+ # At end of file, flush any remaining pending comments
+ END {
+ for (i = 0; i < pending_count; i++) {
+ print pending_lines[i]
+ }
+ }
' "$config_file" > "$tmp_config"
# Preserve file permissions