Fix system installation state directory

The service was failing with 'Read-only file system' when trying to create
discovered_sensors.json in the /etc/sensorpajen config directory.

Changes:
- config.py: Add STATE_DIR for runtime state
  - System mode: /var/lib/sensorpajen (writable at runtime)
  - Dev mode: config/ (same as config directory)
- config.py: Use STATE_DIR for discovered_sensors.json path
- debian/postinst: Create and own /var/lib/sensorpajen
- debian/sensorpajen.service: Add /var/lib/sensorpajen to ReadWritePaths
- debian/postinst: Remove discovered_sensors.json.example copy (created at runtime)

This separates:
- Config: /etc/sensorpajen (static, not updated by service)
- State: /var/lib/sensorpajen (dynamic, updated by service at runtime)
This commit is contained in:
2025-12-28 09:33:26 +01:00
parent 85af215d73
commit fc0399a454
11 changed files with 51 additions and 22 deletions

View File

@@ -26,7 +26,7 @@ SyslogIdentifier=sensorpajen
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/etc/sensorpajen
ReadWritePaths=/etc/sensorpajen /var/lib/sensorpajen
[Install]
WantedBy=multi-user.target