Ensure base config exists before updating allowed_nodes

The installer was only creating base config.yaml in standalone mode,
but update_allowed_nodes() is also called in LXC mode. When the config
didn't exist, update_allowed_nodes() would create an empty file and only
add the allowed_nodes section, missing required fields like
allowed_peer_uids, metrics_address, rate_limit, etc.

This caused the proxy to fail when it tried to parse the incomplete config.

Now creates a proper base config with all required fields if the file
doesn't exist, before any mode-specific configuration is added.
This commit is contained in:
rcourtman 2025-11-14 21:57:16 +00:00
parent f7936cb540
commit 245d6f5b47

View file

@ -999,18 +999,23 @@ register_with_pulse() {
echo "$token" echo "$token"
} }
# Create config file with ACL for Docker containers (standalone mode) # Create base config file if it doesn't exist
if [[ "$STANDALONE" == true ]]; then if [[ ! -f /etc/pulse-sensor-proxy/config.yaml ]]; then
print_info "Creating config file with Docker container ACL..." print_info "Creating base configuration file..."
cat > /etc/pulse-sensor-proxy/config.yaml << 'EOF' cat > /etc/pulse-sensor-proxy/config.yaml << 'EOF'
# Pulse Temperature Proxy Configuration # Pulse Temperature Proxy Configuration
# Allow Docker containers (UID 1000) to connect
allowed_peer_uids: [1000] allowed_peer_uids: [1000]
# Allow ID-mapped root (LXC containers with sub-UID mapping) # Allow ID-mapped root (LXC containers with sub-UID mapping)
allow_idmapped_root: true allow_idmapped_root: true
allowed_idmap_users: allowed_idmap_users:
- root - root
metrics_address: "127.0.0.1:9127"
rate_limit:
per_peer_interval_ms: 333
per_peer_burst: 10
EOF EOF
chown pulse-sensor-proxy:pulse-sensor-proxy /etc/pulse-sensor-proxy/config.yaml chown pulse-sensor-proxy:pulse-sensor-proxy /etc/pulse-sensor-proxy/config.yaml
chmod 0644 /etc/pulse-sensor-proxy/config.yaml chmod 0644 /etc/pulse-sensor-proxy/config.yaml