Phase 6 Complete: Systemd Service Creation
- Created systemd/sensorpajen.service user service unit - Uses %h for portability across systems - Loads environment from EnvironmentFile - Auto-restart with bluetooth capabilities - Comprehensive security settings - Created systemd/README.md - Installation instructions - Service management commands - Troubleshooting guide - Log viewing examples - Updated ROADMAP.md to mark Phase 6 complete
This commit is contained in:
91
ROADMAP.md
91
ROADMAP.md
@@ -161,9 +161,11 @@ Using relative paths for portability across systems:
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Configuration Migration ✓ TODO
|
||||
### Phase 3: Configuration Migration ✅ DONE (2025-12-27)
|
||||
**Goal**: Replace .ini file with JSON and environment variables
|
||||
|
||||
**Notes**: Templates created in Phase 1, successfully tested on Raspberry Pi
|
||||
|
||||
#### Tasks:
|
||||
1. Create sensor mapping converter script
|
||||
- Read sensorer.ini
|
||||
@@ -234,9 +236,11 @@ config/sensorpajen.env
|
||||
debian/files
|
||||
debian/*.log
|
||||
debian/*.substvars
|
||||
### Phase 4: Virtual Environment & Dependencies ✓ TODO
|
||||
### Phase 4: Virtual Environment & Dependencies ✅ DONE (2025-12-27)
|
||||
**Goal**: Set up isolated Python environment
|
||||
|
||||
**Notes**: Tested on Raspberry Pi, paho-mqtt v2.x compatibility fixed
|
||||
|
||||
#### Tasks:
|
||||
1. Create virtual environment:
|
||||
```bash
|
||||
@@ -262,75 +266,34 @@ config/sensorpajen.env
|
||||
|
||||
4. Document virtual environment usage in README
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Bluetooth Permissions ✓ TODO
|
||||
---✅ DONE (2025-12-27)
|
||||
**Goal**: Allow non-root user to access Bluetooth
|
||||
|
||||
**Notes**: Tested on Raspberry Pi with setcap on actual Python binary
|
||||
### Phase 5: Bluetooth Permissions ✅ DONE (2025-12-27)
|
||||
**Goal**: Allow non-root user to access Bluetooth
|
||||
|
||||
**Notes**: Tested on Raspberry Pi with setcap on actual Python binary
|
||||
|
||||
#### Tasks:
|
||||
1. Add user to bluetooth group:
|
||||
```bash
|
||||
sudo usermod -a -G bluetooth fredrik
|
||||
```
|
||||
- ✅ Bluetooth capabilities set with setcap
|
||||
- ✅ Documented in SETUP_ON_PI.md with correct readlink -f usage
|
||||
- ✅ Tested successfully on Raspberry Pi
|
||||
|
||||
2. Set capabilities on Python interpreter (if needed):
|
||||
```bash
|
||||
sudo setcap 'cap_net_raw,cap_net_admin+eip' .venv/bin/python3
|
||||
```%h/sensorpajen
|
||||
EnvironmentFile=%h/sensorpajen/config/sensorpajen.env
|
||||
ExecStart=%h/sensorpajen/.venv/bin/python -m sensorpajen.main
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
# Bluetooth capabilities
|
||||
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
|
||||
|
||||
# Logging
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=sensorpajen
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
|
||||
Note: `%h` expands to the user's home directorycription=Sensorpajen - Bluetooth Temperature Sensor Monitor
|
||||
After=network.target bluetooth.target
|
||||
Wants=bluetooth.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/home/fredrik/dev/sensorpajen
|
||||
EnvironmentFile=/home/fredrik/.config/sensorpajen/sensorpajen.env
|
||||
ExecStart=/home/fredrik/dev/sensorpajen/.venv/bin/python -m sensorpajen.main
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
# Bluetooth capabilities
|
||||
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
|
||||
|
||||
# Logging
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=sensorpajen
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
---
|
||||
|
||||
2. Install service (user service):
|
||||
```bash
|
||||
mkdir -p ~/.config/systemd/user/
|
||||
cp systemd/sensorpajen.service ~/.config/systemd/user/
|
||||
systemctl --user daemon-reload
|
||||
```
|
||||
### Phase 6: Systemd Service Creation ✅ DONE (2025-12-27)
|
||||
**Goal**: Create and configure systemd user service
|
||||
|
||||
3. Enable lingering (service runs without login):
|
||||
```bash
|
||||
sudo loginctl enable-linger fredrik
|
||||
```
|
||||
**Notes**:
|
||||
- User service for easier management (no sudo required)
|
||||
- Service ready for installation on Raspberry Pi
|
||||
- Comprehensive documentation provided
|
||||
|
||||
4. Document systemd commands in README
|
||||
#### Tasks:
|
||||
- ✅ Created systemd/sensorpajen.service
|
||||
- ✅ Created systemd/README.md with full documentation
|
||||
- ✅ Service management and troubleshooting guides included
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user