From 779384b74868434c5087debafaf6cffcdff4d0d6 Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Sun, 31 Aug 2025 19:59:29 +0200 Subject: [PATCH] fix: Correct systemd configuration and Debian package setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix database update service to include config path parameter - Move ConditionACPower from [Timer] to [Unit] section in timer config - Add database directory to ReadWritePaths in main service - Set explicit database path in Debian package config template - Simplify postinst script to be quiet and use consistent skyview-adsb user - Update README.Debian with comprehensive systemd service documentation - Remove confusing dual-user setup in favor of single skyview-adsb user SystemD Configuration Summary: - Main service: skyview-adsb.service with database pre-update - Database service: skyview-database-update.service (oneshot) - Weekly timer: skyview-database-update.timer (Sunday 3AM with randomization) - All services use skyview-adsb user consistently - Database path: /var/lib/skyview-adsb/skyview.db - Config path: /etc/skyview-adsb/config.json 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- debian/DEBIAN/postinst | 29 +-- debian/etc/skyview-adsb/config.json | 54 +++++ .../lib/systemd/system/skyview-adsb.service | 4 +- .../system/skyview-database-update.service | 2 +- .../system/skyview-database-update.timer | 4 +- .../usr/share/doc/skyview-adsb/README.Debian | 189 ++++++++++-------- 6 files changed, 164 insertions(+), 118 deletions(-) create mode 100644 debian/etc/skyview-adsb/config.json diff --git a/debian/DEBIAN/postinst b/debian/DEBIAN/postinst index a686dfc..0622d3b 100755 --- a/debian/DEBIAN/postinst +++ b/debian/DEBIAN/postinst @@ -18,20 +18,8 @@ case "$1" in chown skyview-adsb:skyview-adsb /var/lib/skyview-adsb /var/log/skyview-adsb >/dev/null 2>&1 || true chmod 755 /var/lib/skyview-adsb /var/log/skyview-adsb >/dev/null 2>&1 || true - # Create database directory for skyview user (not skyview-adsb) - mkdir -p /var/lib/skyview >/dev/null 2>&1 || true - if getent passwd skyview >/dev/null 2>&1; then - chown skyview:skyview /var/lib/skyview >/dev/null 2>&1 || true - else - # Create skyview user for database management - if ! getent group skyview >/dev/null 2>&1; then - addgroup --system --quiet skyview - fi - adduser --system --ingroup skyview --home /var/lib/skyview \ - --no-create-home --disabled-password --shell /bin/false --quiet skyview - chown skyview:skyview /var/lib/skyview >/dev/null 2>&1 || true - fi - chmod 755 /var/lib/skyview >/dev/null 2>&1 || true + # Database directory is managed by skyview-adsb user + # (Database path configured in /etc/skyview-adsb/config.json) # Set permissions on config files if [ -f /etc/skyview-adsb/config.json ]; then @@ -55,18 +43,7 @@ case "$1" in fi # Initialize database on first install (but don't auto-enable timer) - if [ ! -f /var/lib/skyview/skyview.db ]; then - echo "Initializing SkyView database..." - sudo -u skyview /usr/bin/skyview-data update >/dev/null 2>&1 || true - echo "Database initialized with safe (public domain) data." - echo "" - echo "To enable automatic weekly updates:" - echo " systemctl enable --now skyview-database-update.timer" - echo "" - echo "To import additional data sources:" - echo " skyview-data list" - echo " skyview-data import " - fi + sudo -u skyview-adsb /usr/bin/skyview-data -config /etc/skyview-adsb/config.json update >/dev/null 2>&1 || true ;; esac diff --git a/debian/etc/skyview-adsb/config.json b/debian/etc/skyview-adsb/config.json new file mode 100644 index 0000000..5b34e89 --- /dev/null +++ b/debian/etc/skyview-adsb/config.json @@ -0,0 +1,54 @@ +{ + "server": { + "host": "", + "port": 8080 + }, + "sources": [ + { + "id": "primary", + "name": "Primary Receiver", + "host": "localhost", + "port": 30005, + "latitude": 0.0, + "longitude": 0.0, + "altitude": 0.0, + "enabled": true + } + ], + "origin": { + "latitude": 0.0, + "longitude": 0.0, + "name": "Receiver Location" + }, + "settings": { + "history_limit": 1000, + "stale_timeout": 60, + "update_rate": 1 + }, + "database": { + "path": "/var/lib/skyview-adsb/skyview.db", + "max_history_days": 7, + "backup_on_upgrade": true, + "max_open_conns": 10, + "max_idle_conns": 5 + }, + "callsign": { + "enabled": true, + "cache_hours": 24, + "privacy_mode": false, + "sources": { + "openflights_airlines": { + "enabled": true, + "priority": 1 + }, + "openflights_airports": { + "enabled": true, + "priority": 2 + }, + "ourairports": { + "enabled": true, + "priority": 3 + } + } + } +} \ No newline at end of file diff --git a/debian/lib/systemd/system/skyview-adsb.service b/debian/lib/systemd/system/skyview-adsb.service index faa3f50..1165552 100644 --- a/debian/lib/systemd/system/skyview-adsb.service +++ b/debian/lib/systemd/system/skyview-adsb.service @@ -39,8 +39,8 @@ RestrictNamespaces=true # Allow network access PrivateNetwork=false -# Allow writing to log directory -ReadWritePaths=/var/log/skyview-adsb +# Allow writing to log and database directories +ReadWritePaths=/var/log/skyview-adsb /var/lib/skyview-adsb # Capabilities CapabilityBoundingSet=CAP_NET_BIND_SERVICE diff --git a/debian/lib/systemd/system/skyview-database-update.service b/debian/lib/systemd/system/skyview-database-update.service index 9ab59ef..0df9b5b 100644 --- a/debian/lib/systemd/system/skyview-database-update.service +++ b/debian/lib/systemd/system/skyview-database-update.service @@ -8,7 +8,7 @@ Wants=network-online.target Type=oneshot User=skyview-adsb Group=skyview-adsb -ExecStart=/usr/bin/skyview-data update +ExecStart=/usr/bin/skyview-data -config /etc/skyview-adsb/config.json update StandardOutput=journal StandardError=journal diff --git a/debian/lib/systemd/system/skyview-database-update.timer b/debian/lib/systemd/system/skyview-database-update.timer index 652903a..dfef7cb 100644 --- a/debian/lib/systemd/system/skyview-database-update.timer +++ b/debian/lib/systemd/system/skyview-database-update.timer @@ -2,6 +2,8 @@ Description=SkyView Database Update Timer Documentation=man:skyview-data(1) Requires=skyview-database-update.service +# Don't start if system is on battery (laptops) +ConditionACPower=true [Timer] # Run weekly on Sunday at 3 AM @@ -10,8 +12,6 @@ OnCalendar=Sun 03:00 RandomizedDelaySec=3600 # Start immediately if system was down during scheduled time Persistent=true -# Don't start if system is on battery (laptops) -ConditionACPower=true [Install] WantedBy=timers.target \ No newline at end of file diff --git a/debian/usr/share/doc/skyview-adsb/README.Debian b/debian/usr/share/doc/skyview-adsb/README.Debian index 44b35c5..0a2da42 100644 --- a/debian/usr/share/doc/skyview-adsb/README.Debian +++ b/debian/usr/share/doc/skyview-adsb/README.Debian @@ -1,125 +1,140 @@ SkyView for Debian ================== -SkyView is a multi-source ADS-B aircraft tracker that connects to dump1090 Beast -format TCP streams and provides a web-based interface for aircraft tracking. +SkyView is a multi-source ADS-B aircraft tracker with comprehensive database integration +for enhanced aviation data and callsign lookup functionality. -Configuration ------------- +Post-Installation Setup +----------------------- -The main configuration file is located at: - /etc/skyview/config.json +After installation, SkyView automatically: +- Creates skyview-adsb user and required directories +- Initializes SQLite database with aviation data sources +- Configures systemd services -This file contains: -- Server configuration (port, host) -- List of dump1090 sources to connect to -- Application settings +Required Configuration +---------------------- -Example configuration for multiple receivers: +Edit the main configuration file: + /etc/skyview-adsb/config.json -```json -{ - "server": { - "host": "", - "port": 8080 - }, - "sources": [ - { - "id": "site1", - "name": "Site 1 Receiver", - "host": "192.168.1.100", - "port": 30005, - "latitude": 51.4700, - "longitude": -0.4600, - "altitude": 50.0, - "enabled": true - }, - { - "id": "site2", - "name": "Site 2 Receiver", - "host": "192.168.1.101", - "port": 30005, - "latitude": 51.4800, - "longitude": -0.4500, - "altitude": 45.0, - "enabled": true - } - ], - "settings": { - "history_limit": 1000, - "stale_timeout": 60, - "update_rate": 1 - } -} -``` +Update at minimum: +- Source coordinates (latitude/longitude) for your ADS-B receiver locations +- Origin coordinates for map center +- ADS-B receiver connection details (host/port) + +See /usr/share/doc/skyview-adsb/CONFIGURATION.md for complete configuration options. Service Management ------------------ +------------------ -SkyView runs as a systemd service. Use these commands to manage it: +SkyView includes two systemd services: - # Start the service - sudo systemctl start skyview +Main Service: + sudo systemctl start skyview-adsb + sudo systemctl enable skyview-adsb # Auto-start on boot + sudo systemctl status skyview-adsb + sudo journalctl -u skyview-adsb -f # View logs - # Stop the service - sudo systemctl stop skyview +Database Update Service (runs weekly): + sudo systemctl start skyview-database-update # Manual update + sudo systemctl enable --now skyview-database-update.timer # Enable weekly updates + sudo systemctl status skyview-database-update.timer - # Restart the service - sudo systemctl restart skyview +Database Management +------------------- - # Enable auto-start on boot - sudo systemctl enable skyview +View database status: + skyview-data -config /etc/skyview-adsb/config.json status - # Disable auto-start on boot - sudo systemctl disable skyview +Update aviation databases: + skyview-data -config /etc/skyview-adsb/config.json update - # Check service status - sudo systemctl status skyview +Optimize database storage: + skyview-data -config /etc/skyview-adsb/config.json optimize - # View logs - sudo journalctl -u skyview -f +List available data sources: + skyview-data -config /etc/skyview-adsb/config.json list Web Interface ------------- +------------- -Once started, the web interface is available at: - http://localhost:8080 +Access the web interface at: http://localhost:8080 -The interface provides: +Features include: - Real-time aircraft tracking map -- Aircraft table with filtering and sorting -- Statistics dashboard -- Coverage and signal strength visualization -- 3D radar view (optional) +- Enhanced callsign information with airline details +- Database status monitoring at /database +- Aircraft history and trail visualization +- Coverage and signal strength analysis +- 3D radar view + +External Data Sources +--------------------- + +SkyView includes three aviation databases: +- OpenFlights Airlines (~6,162 airlines) +- OpenFlights Airports (~7,698 airports) +- OurAirports (~83,557 airports worldwide) + +Privacy Mode: Set "privacy_mode": true in config to disable external data loading. Files and Directories --------------------- +--------------------- - /usr/bin/skyview - Main executable - /etc/skyview/config.json - Configuration file - /var/lib/skyview/ - Application data directory - /var/log/skyview/ - Log files - /lib/systemd/system/skyview.service - Systemd service file +Executables: + /usr/bin/skyview - Main ADS-B tracker service + /usr/bin/skyview-data - Database management utility + /usr/bin/beast-dump - Raw ADS-B data analysis tool + +Configuration: + /etc/skyview-adsb/config.json - Main configuration file + +Data: + /var/lib/skyview-adsb/ - Application and database directory + /var/log/skyview-adsb/ - Log files + +Services: + /lib/systemd/system/skyview-adsb.service - Main service + /lib/systemd/system/skyview-database-update.service - Database updater + /lib/systemd/system/skyview-database-update.timer - Weekly update timer + +Documentation: + /usr/share/doc/skyview-adsb/CONFIGURATION.md - Complete configuration guide + /usr/share/doc/skyview-adsb/DATABASE.md - Database schema reference Security -------- -SkyView runs as the unprivileged 'skyview' user for security. The service has -restricted capabilities and filesystem access. +SkyView runs as the unprivileged 'skyview-adsb' user with comprehensive systemd security hardening: +- NoNewPrivileges, ProtectSystem=strict, ProtectHome=true +- Private temporary directories and device access restrictions +- Restricted namespaces and capabilities Troubleshooting --------------- +--------------- -1. Check service status: - sudo systemctl status skyview +1. Check main service status: + sudo systemctl status skyview-adsb 2. View recent logs: - sudo journalctl -u skyview --no-pager -l + sudo journalctl -u skyview-adsb --no-pager -l -3. Test configuration: - sudo -u skyview /usr/bin/skyview -config /etc/skyview/config.json +3. Test database connectivity: + skyview-data -config /etc/skyview-adsb/config.json status -4. Check network connectivity to dump1090 sources: - telnet +4. Manual database update: + sudo -u skyview-adsb skyview-data -config /etc/skyview-adsb/config.json update -For more information, visit: https://github.com/skyview/skyview \ No newline at end of file +5. Check ADS-B source connectivity: + telnet + +6. View database information in web interface: + http://localhost:8080/database + +For complete documentation, see: +- /usr/share/doc/skyview-adsb/CONFIGURATION.md +- /usr/share/doc/skyview-adsb/DATABASE.md +- man skyview(1), man skyview-data(1), man beast-dump(1) + +Project repository: https://kode.naiv.no/olemd/skyview \ No newline at end of file