Phase 8: Implement Debian package creation (2025-12-27)
- Create debian/ directory structure with all required files: - control: Package metadata and dependencies - compat: Debhelper compatibility level - changelog: Version history - rules: Build instructions - install: File installation mappings - postinst: Post-installation setup (user, venv, setcap) - prerm: Pre-removal script (stop service) - postrm: Post-removal script (cleanup, preserve config) - sensorpajen.service: System-wide systemd unit - Update config.py to support dual-mode operation: - Auto-detects system installation (/opt/sensorpajen) - Uses /etc/sensorpajen for config in system mode - Falls back to PROJECT_ROOT/config for development - Update scripts/approve-sensors.sh for system paths: - Detects system vs development installation - Uses correct venv and config paths - Create scripts/verify-deb.sh: Automated build and verification - Create debian/README.md: Comprehensive packaging documentation Package features: - System-wide installation to /opt/sensorpajen/ - Configuration in /etc/sensorpajen/ (preserved on upgrade/remove) - Dedicated sensorpajen system user - Automatic venv creation with dependencies - Bluetooth capabilities set automatically - Service auto-enabled but waits for config before starting - Dual-mode code supports both system and development installations
This commit is contained in:
@@ -1,23 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Wrapper script for approve-sensors that sets minimal required env vars
|
||||
# Wrapper script for approve-sensors that works in both dev and system mode
|
||||
|
||||
# Get script directory
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
|
||||
# Detect installation type
|
||||
if [ -d "/opt/sensorpajen" ]; then
|
||||
# System installation
|
||||
PROJECT_ROOT="/opt/sensorpajen"
|
||||
VENV_PATH="/opt/sensorpajen/venv"
|
||||
|
||||
# Load config from system location
|
||||
if [ -f "/etc/sensorpajen/sensorpajen.env" ]; then
|
||||
set -a
|
||||
source /etc/sensorpajen/sensorpajen.env
|
||||
set +a
|
||||
else
|
||||
echo "Warning: /etc/sensorpajen/sensorpajen.env not found"
|
||||
# Set minimal defaults
|
||||
export MQTT_HOST="${MQTT_HOST:-localhost}"
|
||||
export MQTT_PORT="${MQTT_PORT:-1883}"
|
||||
fi
|
||||
else
|
||||
# Development installation
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
PROJECT_ROOT="$( cd "$SCRIPT_DIR/.." && pwd )"
|
||||
VENV_PATH="$PROJECT_ROOT/.venv"
|
||||
|
||||
# Set minimal required environment variables
|
||||
export MQTT_HOST="${MQTT_HOST:-localhost}"
|
||||
export MQTT_PORT="${MQTT_PORT:-1883}"
|
||||
|
||||
# Set minimal required environment variables
|
||||
export MQTT_HOST="${MQTT_HOST:-localhost}"
|
||||
export MQTT_PORT="${MQTT_PORT:-1883}"
|
||||
|
||||
# Load actual config if it exists (will override defaults)
|
||||
if [ -f "$PROJECT_ROOT/config/sensorpajen.env" ]; then
|
||||
set -a
|
||||
source "$PROJECT_ROOT/config/sensorpajen.env"
|
||||
set +a
|
||||
# Load actual config if it exists (will override defaults)
|
||||
if [ -f "$PROJECT_ROOT/config/sensorpajen.env" ]; then
|
||||
set -a
|
||||
source "$PROJECT_ROOT/config/sensorpajen.env"
|
||||
set +a
|
||||
fi
|
||||
fi
|
||||
|
||||
# Activate virtual environment
|
||||
source "$PROJECT_ROOT/.venv/bin/activate"
|
||||
if [ -f "$VENV_PATH/bin/activate" ]; then
|
||||
source "$VENV_PATH/bin/activate"
|
||||
else
|
||||
echo "Error: Virtual environment not found at $VENV_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run the approve-sensors command
|
||||
python -m sensorpajen.approve_sensors "$@"
|
||||
|
||||
Reference in New Issue
Block a user