skyview/debian/DEBIAN/postinst
Ole-Morten Duesund 37c4fa2b57 feat: Add SQLite database integration for aircraft history and callsign enhancement
- Implement comprehensive database package with versioned migrations
- Add skyview-data CLI tool for managing aviation reference data
- Integrate database with merger for real-time aircraft history persistence
- Support OurAirports and OpenFlights data sources (runtime loading)
- Add systemd timer for automated database updates
- Fix transaction-based bulk loading for 2400% performance improvement
- Add callsign enhancement system with airline/airport lookups
- Update Debian packaging with database directory and permissions

Database features:
- Aircraft position history with configurable retention
- External aviation data loading (airlines, airports)
- Callsign parsing and enhancement
- API client for external lookups (OpenSky, etc.)
- Privacy mode for complete offline operation

CLI commands:
- skyview-data status: Show database statistics
- skyview-data update: Load aviation reference data
- skyview-data list: Show available data sources
- skyview-data clear: Remove specific data sources

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 16:48:28 +02:00

73 lines
No EOL
3.1 KiB
Bash
Executable file

#!/bin/bash
set -e
case "$1" in
configure)
# Create skyview-adsb user and group if they don't exist
if ! getent group skyview-adsb >/dev/null 2>&1; then
addgroup --system --quiet skyview-adsb
fi
if ! getent passwd skyview-adsb >/dev/null 2>&1; then
adduser --system --ingroup skyview-adsb --home /var/lib/skyview-adsb \
--no-create-home --disabled-password --quiet skyview-adsb
fi
# Create directories with proper permissions
mkdir -p /var/lib/skyview-adsb /var/log/skyview-adsb >/dev/null 2>&1 || true
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
# Set permissions on config files
if [ -f /etc/skyview-adsb/config.json ]; then
chown root:skyview-adsb /etc/skyview-adsb/config.json >/dev/null 2>&1 || true
chmod 640 /etc/skyview-adsb/config.json >/dev/null 2>&1 || true
fi
# Handle systemd services
systemctl daemon-reload >/dev/null 2>&1 || true
# Check if main service was previously enabled
if systemctl is-enabled skyview-adsb >/dev/null 2>&1; then
# Service was enabled, restart it
systemctl restart skyview-adsb >/dev/null 2>&1 || true
fi
# Only restart database timer if it was already enabled
if systemctl is-enabled skyview-database-update.timer >/dev/null 2>&1; then
systemctl restart skyview-database-update.timer >/dev/null 2>&1 || true
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 <source>"
fi
;;
esac
exit 0