- 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
49 lines
1.4 KiB
Bash
Executable File
49 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Wrapper script for approve-sensors that works in both dev and system mode
|
|
|
|
# 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}"
|
|
|
|
# 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
|
|
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 "$@"
|